Exemple #1
0
 public void Add(PropertyIDs propertyID, UInt32 propertyValue)
 {
     ShapeProperty prop = new ShapeProperty();
     prop.PropertyID = propertyID;
     prop.PropertyValue = propertyValue;
     prop.IsBlipID = propertyID == PropertyIDs.BlipId;
     Properties.Add(prop);
 }
 private void AddPropsToObservableCollection()
 {
     ShapeProperties.Clear();
     foreach (string prop in _shapeprops)
     {
         ShapeProperty prp = new ShapeProperty()
         {
             Name = prop, Value = null
         };
         ShapeProperties.Add(prp);
     }
 }
        //construed from documentation - may be wrong - wait and see
        private void HandleExtAttr()
        {
            if (string.IsNullOrEmpty(m_dataObject.Ext))
                return;

            if (m_dataObject.Lock == "t")
            {
                switch (m_dataObject.Ext)
                {
                    case "edit":
                        {
                            ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.LockText, true);
                            m_dataObject.Properties.Items.Add(sp);
                            break;
                        }
                        //don't know what if anything these mean
                    case "backwardCompatible":
                        break;
                    case "view":
                        break;
                }
            }
        }
 private static void ResolveRelativeHeight(string relHeight, ShapeProperties shapeProps)
 {
     switch (relHeight)
     {
         case "margin":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelV, 0);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "outer-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelV, 5);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "top-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelV, 2);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "inner-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelV, 4);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "bottom-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelV, 3);
                 shapeProps.Items.Add(sp);
                 break;
             }
         default:
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelV, 1);//page
                 shapeProps.Items.Add(sp);
                 break;
             }
     }
 }
 private static void ResolveRelativeWidth(string relWidth, ShapeProperties shapeProps)
 {
     switch (relWidth)
     {
         case "margin":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelH, 0);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "outer-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelH, 5);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "left-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelH, 2);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "inner-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelH, 4);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "right-margin-area":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelH, 3);
                 shapeProps.Items.Add(sp);
                 break;
             }
         default:
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.SizeRelH, 1);//page
                 shapeProps.Items.Add(sp);
                 break;
             }
      }
 }
     private static void ResolveRelPosHorizontal(string position, ShapeProperties shapeProps)
     {
         switch (position)
         {
             case "margin":
                 {
                     ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelH, (Int32)ShapeProperty.HRelativePosition.Margin);
                     shapeProps.Items.Add(sp);
                     break;
                 }
             case "page":
                 {
                     ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelH, (Int32)ShapeProperty.HRelativePosition.Page);
                     shapeProps.Items.Add(sp);
                     break;
                 }
             case "text":
                 {
                     ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelH, (Int32)ShapeProperty.HRelativePosition.Column);
                     shapeProps.Items.Add(sp);
                     break;
                 }
             case "char":
                 {
                     ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelH, (Int32)ShapeProperty.HRelativePosition.Character);
                     shapeProps.Items.Add(sp);
                     break;
                 }
         }
 
     }
 private static void ResolveRelPosVertical(string position, ShapeProperties shapeProps)
 {
     switch (position)
     {
         case "margin":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelV, (Int32)ShapeProperty.VRelativePosition.Margin);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "page":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelV, (Int32)ShapeProperty.VRelativePosition.Page);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "text":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelV, (Int32)ShapeProperty.VRelativePosition.Paragraph);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "line":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosRelV, (Int32)ShapeProperty.VRelativePosition.Line);
                 shapeProps.Items.Add(sp);
                 break;
             }
     }
 }
Exemple #8
0
        void HandleLockRotationAttr(string attrValue)
        {
            if (string.IsNullOrEmpty(attrValue))
                return;

            if (attrValue == "t")
            {
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.LockRotation, true);
                m_dataObject.Properties.Items.Add(sp);
            }
            else
            {
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.LockRotation, false);
                m_dataObject.Properties.Items.Add(sp);
            }
        }
 private static void ResolvePositionHorizontal(string position, ShapeProperties shapeProps)
 {
     switch (position)
     {
         case "absolute":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosH, (Int32)ShapeProperty.HAlignment.NotSet);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "left":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosH, (Int32)ShapeProperty.HAlignment.Left);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "center":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosH, (Int32)ShapeProperty.HAlignment.Center);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "right":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosH, (Int32)ShapeProperty.HAlignment.Right);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "inside":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosH, (Int32)ShapeProperty.HAlignment.Inside);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "outside":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosH, (Int32)ShapeProperty.HAlignment.Outside);
                 shapeProps.Items.Add(sp);
                 break;
             }
     }
 }
 private static void ResolvePositionVertical(string position, ShapeProperties shapeProps)
 {
     switch (position)
     {
         case "absolute":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosV, (Int32)ShapeProperty.VAlignment.NotSet);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "top":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosV, (Int32)ShapeProperty.VAlignment.Column);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "center":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosV, (Int32)ShapeProperty.VAlignment.Center);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "bottom":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosV, (Int32)ShapeProperty.VAlignment.Bottom);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "inside":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosV, (Int32)ShapeProperty.VAlignment.Inside);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "outside":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PosV, (Int32)ShapeProperty.VAlignment.Outside);
                 shapeProps.Items.Add(sp);
                 break;
             }
     }
 }
 private static void ResolveFlipDirection(string flip, ShapeProperties shapeProps)
 {
     switch (flip)
     {
         case "x":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.FlipH, true);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "y":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.FlipV, true);
                 shapeProps.Items.Add(sp);
                 break;
             }
             //don't know if the next two interpretations are correct - just have to wait for an example
         case "xy":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.FlipH, true);
                 shapeProps.Items.Add(sp);
                 sp = new ShapeProperty(ShapeProperty.PropertyType.FlipV, true);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "yx":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.FlipH, true);
                 shapeProps.Items.Add(sp);
                 sp = new ShapeProperty(ShapeProperty.PropertyType.FlipV, true);
                 shapeProps.Items.Add(sp);
                 break;
             }
     }
 }
        //don't always get 4 
        public static void ResolveInset(string insetString, ShapeProperties shapeProps)
        {
            if (string.IsNullOrEmpty(insetString))
                return;

            string[] insets = GetParameters(',', insetString);

            int count = insets.Length;

            if (count > 0)
            {
                int iLeft = ResolvePosition(insets[0], ShapeProperties.RtfMeasurementUnits.EMU);
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.DxTextLeft, iLeft);
                shapeProps.Items.Add(sp);
            }

            if (count > 1)
            {
                int iTop = ResolvePosition(insets[1], ShapeProperties.RtfMeasurementUnits.EMU);
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.DyTextTop, iTop);
                shapeProps.Items.Add(sp);
            }

            if (count > 2)
            {
                int iRight = ResolvePosition(insets[2], ShapeProperties.RtfMeasurementUnits.EMU);
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.DxTextRight, iRight);
                shapeProps.Items.Add(sp);
            }

            if (count > 3)
            {
                int iBottom = ResolvePosition(insets[3], ShapeProperties.RtfMeasurementUnits.EMU);
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.DyTextBottom, iBottom);
                shapeProps.Items.Add(sp);
            }
        }
        public static void ResolveCoordinates(string coordOrigin, string coordSize, ShapeProperties shapeProps)
        {
            if (string.IsNullOrEmpty(coordOrigin))
                return;

            string[] origins = GetParameters(',', coordOrigin);
            //this may need more work, but for the moment....
            int gLeft = 0;
            int gTop = 0;
            if (origins.Length > 0)
            {
                gLeft = Int32.Parse(origins[0]);
            }
            if (origins.Length > 1)
            {
                gTop = Int32.Parse(origins[1]);
            }

            ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.GroupLeft, gLeft);
            shapeProps.Items.Add(sp);
            sp = new ShapeProperty(ShapeProperty.PropertyType.GroupTop, gTop);
            shapeProps.Items.Add(sp);

            if (string.IsNullOrEmpty(coordSize))
                return;

            string[] sizes = GetParameters(',', coordSize);
            int gRight = Int32.Parse(sizes[0]);
            gRight = gRight + gLeft;
            int gBottom = Int32.Parse(sizes[1]);
            gBottom = gBottom + gTop;


            sp = new ShapeProperty(ShapeProperty.PropertyType.GroupRight, gRight);
            shapeProps.Items.Add(sp);
            sp = new ShapeProperty(ShapeProperty.PropertyType.GroupBottom, gBottom);
            shapeProps.Items.Add(sp);
        }
 public static void ResolveParameter(string[] parameter, ShapeProperties shapeProps)
 {
     switch (parameter[0])
     {
         case "flip":
             {
                 ResolveFlipDirection(parameter[1], shapeProps);
                 break;
             }
         case "height":
             {
                 shapeProps.BottomPosition = ResolvePosition(parameter[1], ShapeProperties.RtfMeasurementUnits.Twips);
                 break;
             }
         case "margin-left":
         case "left":
             {
                 shapeProps.LeftPosition = ResolvePosition(parameter[1], ShapeProperties.RtfMeasurementUnits.Twips); ;
                 break;
             }
         case "margin-bottom":
             {
                 break;
             }
         case "margin-right":
             {
                 break;
             }
         case "mso-height-percent":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PctHeight, Int32.Parse(parameter[1]));
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "mso-height-relative":
             {
                 ResolveRelativeHeight(parameter[1], shapeProps);
                 break;
             }
         case "mso-position-horizontal":
             {
                 ResolvePositionHorizontal(parameter[1], shapeProps);
                 break;
             }
         case "mso-position-horizontal-relative":
             {
                 ResolveRelPosHorizontal(parameter[1], shapeProps);
                 break;
             }
         case "mso-position-vertical":
             {
                 ResolvePositionVertical(parameter[1], shapeProps);
                 break;
             }
         case "mso-position-vertical-relative":
             {
                 ResolveRelPosVertical(parameter[1], shapeProps);
                 break;
             }
         case "mso-width-percent":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.PctWidth, Int32.Parse(parameter[1]));
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "mso-width-relative":
             {
                 ResolveRelativeWidth(parameter[1], shapeProps);
                 break;
             }
         case "mso-wrap-distance-bottom":
             {
                 break;
             }
         case "mso-wrap-distance-left":
             {
                 break;
             }
         case "mso-wrap-distance-right":
             {
                 break;
             }
         case "mso-wrap-distance-top":
             {
                 break;
             }
         case "mso-wrap-edited":
             {
                 break;
             }
         case "mso-wrap-style":
             {
                 ResolveWrapStyle(parameter[1], shapeProps);
                 break;
             }
         case "position":
             {
                 ResolveElementPosition(parameter[1], shapeProps);
                 break;
             }
         case "rotation":
             {
                 break;
             }
         case "margin-top":
         case "top":
             {
                 shapeProps.TopPosition = ResolvePosition(parameter[1], ShapeProperties.RtfMeasurementUnits.Twips);
                 break;
             }
         case "visibility":
             {
                 break;
             }
         case "width":
             {
                 shapeProps.RightPosition = ResolvePosition(parameter[1], ShapeProperties.RtfMeasurementUnits.Twips);
                 break;
             }
         case "z-index":
             {   //this is used to infer the \shpwr token value in rtf - need to combine it with the use of the
                 // wrapcoords attribute to finally resolve the actual value for the ShapeWrap property
                 int it = Int32.Parse(parameter[1]);
                 if (it > 0)
                 {
                     shapeProps.WrappingType = ShapeProperties.WrappingTypes.NoneTxInFront;
                     ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.ZIndex, it);
                     shapeProps.Items.Add(sp);
                 }
                 else
                 {
                     shapeProps.WrappingType = ShapeProperties.WrappingTypes.NoneTxBehind;
                 }
                 break;
             }
             //Textbox only propertes
         case "direction":
             {
                 break;
             }
         case "layout-flow":
             {
                 break;
             }
         case "mso-direction-alt":
             {
                 break;
             }
         case "mso-fit-shape-to-text":
             {
                 ShapeProperty sp;
                 if (parameter[1] == "t")
                 {
                     sp = new ShapeProperty(ShapeProperty.PropertyType.FitShapeToText, true);
                 }
                 else
                 {
                     sp = new ShapeProperty(ShapeProperty.PropertyType.FitShapeToText, false);
                 }
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "mso-fit-text-to-shape":
             {
                 break;
             }
         case "mso-layout-flow-alt":
             {
                 break;
             }
         case "mso-next-textbox":
             {
                 break;
             }
         case "mso-rotate":
             {
                 break;
             }
         case "mso-text-scale":
             {
                 break;
             }
         case "v-text-anchor":
             {
                 ResolveVTextAnchorPosition(parameter[1], shapeProps);
                 break;
             }
         //TextPath only properties
         case "font":
             {
                 break;
             }
         case "font-family":
             {
                 break;
             }
         case "font-size":
             {
                 break;
             }
         case "font-style":
             {
                 break;
             }
         case "font-variant":
             {
                 break;
             }
         case "font-weight":
             {
                 break;
             }
         case "mso-text-shadow":
             {
                 break;
             }
         case "text-decoration":
             {
                 break;
             }
         case "v-rotate-letters":
             {
                 break;
             }
         case "v-same-letter-heights":
             {
                 break;
             }
         case "v-text-align":
             {
                 break;
             }
         case "v-text-kern":
             {
                 break;
             }
         case "v-text-reverse":
             {
                 break;
             }
         case "v-text-spacing-mode":
             {
                 break;
             }
         case "v-text-spacing":
             {
                 break;
             }
     }
 }
        //rtf has 5 different flags for this
        //docx appears to only have two
        private static void ResolveWrapStyle(string style, ShapeProperties shapeProps)
        { 
            switch(style)
            {
                case "none":
                    {
                        ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.WrapText, 2);
                        shapeProps.Items.Add(sp);
                        break;
                    }
                default:
                    {
                        ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.WrapText, 0);
                        shapeProps.Items.Add(sp);
                        break;
                    }
            }

        }
Exemple #16
0
        void HandleAspectRatioAttr(string attrValue)
        {
            if (string.IsNullOrEmpty(attrValue) )
                return;

            if(attrValue == "t")
            {
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.LockAspectRatio, true);
                m_dataObject.Properties.Items.Add(sp);
                //this appears to be a default thing in the rtf tho' can't find any documentation
                sp = new ShapeProperty(ShapeProperty.PropertyType.LockPosition, true);
                m_dataObject.Properties.Items.Add(sp);
                sp = new ShapeProperty(ShapeProperty.PropertyType.LockRotation, true);
                m_dataObject.Properties.Items.Add(sp);
            }
            else
            {
                ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.LockAspectRatio, false);
                m_dataObject.Properties.Items.Add(sp);
                //this appears to be a default thing in the rtf tho' can't find any documentation
                sp = new ShapeProperty(ShapeProperty.PropertyType.LockPosition, false);
                m_dataObject.Properties.Items.Add(sp);
                sp = new ShapeProperty(ShapeProperty.PropertyType.LockRotation, false);
                m_dataObject.Properties.Items.Add(sp);
            }
        }
 //the rtf output does not work for this as we also need to ouput an additional flag 
 // in the doc formatting section (\notvatxbx)  I have done nothing about this for the moment as we 
 //don't handle this rtf token at all and therefore even in rtf our output is wrong
 private static void ResolveVTextAnchorPosition(string position, ShapeProperties shapeProps)
 {
     switch (position)
     {
         case "top":
         case "top-baseline":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 0);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "middle":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 1);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "bottom":
         case "bottom-baseline":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 2);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "top-center":
         case "top-center-baseline":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 3);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "middle-center":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 4);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "bottom-center":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 5);
                 shapeProps.Items.Add(sp);
                 break;
             }
         case "bottom-center-baseline":
             {
                 ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.AnchorText, 6);
                 shapeProps.Items.Add(sp);
                 break;
             }
     }
 }
Exemple #18
0
        //construed from documentation - may be wrong - wait and see
        void HandleExtAttr(string ext, string aspectRatio)
        { 
            if (string.IsNullOrEmpty(ext) )
                return;

            if (aspectRatio == "t")
            {
                switch (ext)
                {
                    case "edit":
                        {
                            ShapeProperty sp = new ShapeProperty(ShapeProperty.PropertyType.LockText, true);
                            m_dataObject.Properties.Items.Add(sp);
                            break;
                        }
                }
            }
        }
 set => SetValue(ShapeProperty, value);