Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sourceLineNumbers"></param>
        /// <param name="attrib"></param>
        /// <param name="publishInfo"></param>
        /// <param name="visioVersion"></param>

        private void ParseVisioVersionAttribute(SourceLineNumberCollection sourceLineNumbers, XmlAttribute attrib,
                                                VisioPublishInfo publishInfo, VisioVersion visioVersion)
        {
            if (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
            {
                publishInfo.VisioVersion |= visioVersion;
            }
            else
            {
                publishInfo.VisioVersion &= ~visioVersion;
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="visioContentType"></param>
        /// <param name="sourceLineNumbers"></param>
        /// <param name="attrib"></param>
        /// <param name="publishInfo"></param>
        /// <param name="addonAttrs"></param>

        private void ParseAddonAttrs(VisioContentType visioContentType, SourceLineNumberCollection sourceLineNumbers,
                                     XmlAttribute attrib, VisioPublishInfo publishInfo, AddonAttrs addonAttrs)
        {
            if (visioContentType != VisioContentType.Addon)
            {
                Core.UnexpectedAttribute(sourceLineNumbers, attrib);
            }
            else
            {
                if (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
                {
                    publishInfo.AddonAttrs |= addonAttrs;
                }
                else
                {
                    publishInfo.AddonAttrs &= ~addonAttrs;
                }
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sourceLineNumbers"></param>
 /// <param name="attrib"></param>
 /// <param name="publishInfo"></param>
 /// <param name="visioVersion"></param>
 private void ParseVisioVersionAttribute(SourceLineNumberCollection sourceLineNumbers, XmlAttribute attrib,
                                         VisioPublishInfo publishInfo, VisioVersion visioVersion)
 {
     if (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
         publishInfo.VisioVersion |= visioVersion;
     else
         publishInfo.VisioVersion &= ~visioVersion;
 }
        /// <summary>
        /// Parses a "Visio" element.
        /// </summary>
        /// <param name="node">Element to parse.</param>
        /// <param name="contextComponentId">Identifier for parent component.</param>
        /// <param name="fileName"></param>
        /// <param name="visioContentType"></param>
        private void ParseVisioElement(XmlNode node, string contextComponentId, string fileName, VisioContentType visioContentType)
        {
            var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);

            string component = null;
            string feature = null;

            if (visioContentType != GetVisioContentType(fileName))
                Core.OnMessage(VisioWarnings.InvalidFileExtension(sourceLineNumbers, fileName, Enum.GetName(typeof(VisioContentType), visioContentType)));

            var publishInfo = new VisioPublishInfo(fileName);

            if (node.Attributes != null)
            foreach (XmlAttribute attrib in node.Attributes)
            {
                switch (attrib.LocalName)
                {
                    case "Feature":
                        feature = Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Feature", feature);
                        break;

                    case "Component":
                        component = Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Component", component);
                        break;

                    case "Visio2003":
                        ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2003);
                        break;

                    case "Visio2007":
                        ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2007);
                        break;

                    case "Visio2010":
                        ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2010);
                        break;

                    case "Visio2013":
                        ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2013);
                        break;

                    case "VisioEdition":
                        publishInfo.VisioEdition = ParseVisioEditionAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "Language":
                        publishInfo.VisioLanguage = ParseVisioLanguageCode(sourceLineNumbers, attrib);
                        break;

                    case "MenuPath":
                        if (visioContentType == VisioContentType.Template || visioContentType == VisioContentType.Stencil || visioContentType == VisioContentType.Addon)
                            publishInfo.MenuPath = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "AltNames":
                        if (visioContentType == VisioContentType.Template || visioContentType == VisioContentType.Stencil)
                            publishInfo.AltNames = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "QuickShapeCount":
                        if (visioContentType == VisioContentType.Stencil)
                            publishInfo.QuickShapesCount = ParseUint(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "FeaturedTemplate":
                        if (visioContentType == VisioContentType.Template)
                            publishInfo.FeaturedTemplate = (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib));
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "LocalizedName":
                        if (visioContentType == VisioContentType.Addon)
                            publishInfo.LocalizedName = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "UniversalName":
                        if (visioContentType == VisioContentType.Addon)
                            publishInfo.UniversalName = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "Ordinal":
                        if (visioContentType == VisioContentType.Addon)
                            publishInfo.Ordinal = ParseUint(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "PerformsActions":
                        ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.PerformsActions);
                        break;

                    case "HasAboutBox":
                        ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.HasAboutBox);
                        break;

                    case "ProvidesHelp":
                        ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.ProvidesHelp);
                        break;

                    case "DisplayWaitCursor":
                        ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.DisplayWaitCursor);
                        break;

                    case "HideInUI":
                        ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.HideInUI);
                        break;

                    case "EnablingPolicy":
                        if (visioContentType == VisioContentType.Addon)
                            publishInfo.EnablingPolicy = ParseEnablingPolicy(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "StaticEnableConditions":
                        if (visioContentType == VisioContentType.Addon)
                            publishInfo.StaticEnableConditions = ParseStaticEnableConditions(sourceLineNumbers, attrib);
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    case "InvokeOnStartup":
                        if (visioContentType == VisioContentType.Addon)
                            publishInfo.InvokeOnStartup = (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib));
                        else
                            Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;

                    default:
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;
                }
            }

            if (string.IsNullOrEmpty(publishInfo.MenuPath))
            {
                if (visioContentType == VisioContentType.Template || visioContentType == VisioContentType.Stencil)
                    Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "MenuPath"));
            }

            if (publishInfo.VisioVersion == VisioVersion.Default)
                publishInfo.VisioVersion = VisioPublishInfo.GetDefaultVisioVersion(fileName);

            if (publishInfo.VisioEdition == VisioEdition.Default)
                publishInfo.VisioEdition = (VisioEdition.X86 | VisioEdition.X64);

            if ((publishInfo.VisioEdition & VisioEdition.X86) == VisioEdition.X86)
                Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction", "SetConfigChangeID");

            if ((publishInfo.VisioEdition & VisioEdition.X64) == VisioEdition.X64)
                Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction", "SetConfigChangeID64");

            if (Core.EncounteredError)
                return;

            var featureId = feature ?? Guid.Empty.ToString("B");
            var componentId = component ?? contextComponentId;

            foreach (var rowInfo in publishInfo.GenerateRowInfos(visioContentType, fileName))
            {
                var row = Core.CreateRow(sourceLineNumbers, "PublishComponent");

                row[0] = rowInfo.VisioComponentId;
                row[1] = rowInfo.Qualifier;
                row[2] = componentId;
                row[3] = rowInfo.AppData;
                row[4] = featureId;
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="visioContentType"></param>
 /// <param name="sourceLineNumbers"></param>
 /// <param name="attrib"></param>
 /// <param name="publishInfo"></param>
 /// <param name="addonAttrs"></param>
 private void ParseAddonAttrs(VisioContentType visioContentType, SourceLineNumberCollection sourceLineNumbers,
                              XmlAttribute attrib, VisioPublishInfo publishInfo, AddonAttrs addonAttrs)
 {
     if (visioContentType != VisioContentType.Addon)
         Core.UnexpectedAttribute(sourceLineNumbers, attrib);
     else
     {
         if (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
             publishInfo.AddonAttrs |= addonAttrs;
         else
             publishInfo.AddonAttrs &= ~addonAttrs;
     }
 }
Exemple #6
0
        /// <summary>
        /// Parses a "Visio" element.
        /// </summary>
        /// <param name="node">Element to parse.</param>
        /// <param name="contextComponentId">Identifier for parent component.</param>
        /// <param name="fileName"></param>
        /// <param name="visioContentType"></param>
        private void ParseVisioElement(XmlElement node, string contextComponentId, string fileName, VisioContentType visioContentType)
        {
            var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);

            string component = null;
            string feature   = null;

            if (visioContentType != GetVisioContentType(fileName))
            {
                Core.OnMessage(VisioWarnings.InvalidFileExtension(sourceLineNumbers, fileName, Enum.GetName(typeof(VisioContentType), visioContentType)));
            }

            var publishInfo = new VisioPublishInfo(fileName);

            foreach (XmlAttribute attrib in node.Attributes)
            {
                switch (attrib.LocalName)
                {
                case "Feature":
                    feature = Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                    Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Feature", feature);
                    break;

                case "Component":
                    component = Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                    Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Component", component);
                    break;

                case "Visio2003":
                    ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2003);
                    break;

                case "Visio2007":
                    ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2007);
                    break;

                case "Visio2010":
                    ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2010);
                    break;

                case "Visio2013":
                    ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2013);
                    break;

                case "Visio2016":
                    ParseVisioVersionAttribute(sourceLineNumbers, attrib, publishInfo, VisioVersion.Visio2016);
                    break;

                case "VisioEdition":
                    publishInfo.VisioEdition = ParseVisioEditionAttributeValue(sourceLineNumbers, attrib);
                    break;

                case "Language":
                    publishInfo.VisioLanguage = ParseVisioLanguageCode(sourceLineNumbers, attrib);
                    break;

                case "MenuPath":
                    if (visioContentType == VisioContentType.Template || visioContentType == VisioContentType.Stencil || visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.MenuPath = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;

                case "AltNames":
                    if (visioContentType == VisioContentType.Template || visioContentType == VisioContentType.Stencil)
                    {
                        publishInfo.AltNames = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;



                case "QuickShapeCount":
                    if (visioContentType == VisioContentType.Stencil)
                    {
                        publishInfo.QuickShapesCount = ParseUint(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;



                case "FeaturedTemplate":
                    if (visioContentType == VisioContentType.Template)
                    {
                        publishInfo.FeaturedTemplate = (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib));
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;



                case "LocalizedName":
                    if (visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.LocalizedName = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;

                case "UniversalName":
                    if (visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.UniversalName = Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;

                case "Ordinal":
                    if (visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.Ordinal = ParseUint(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;


                case "PerformsActions":
                    ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.PerformsActions);
                    break;

                case "HasAboutBox":
                    ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.HasAboutBox);
                    break;

                case "ProvidesHelp":
                    ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.ProvidesHelp);
                    break;

                case "DisplayWaitCursor":
                    ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.DisplayWaitCursor);
                    break;

                case "HideInUI":
                    ParseAddonAttrs(visioContentType, sourceLineNumbers, attrib, publishInfo, AddonAttrs.HideInUI);
                    break;

                case "EnablingPolicy":
                    if (visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.EnablingPolicy = ParseEnablingPolicy(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;

                case "StaticEnableConditions":
                    if (visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.StaticEnableConditions = ParseStaticEnableConditions(sourceLineNumbers, attrib);
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;

                case "InvokeOnStartup":
                    if (visioContentType == VisioContentType.Addon)
                    {
                        publishInfo.InvokeOnStartup = (YesNoType.Yes == Core.GetAttributeYesNoValue(sourceLineNumbers, attrib));
                    }
                    else
                    {
                        Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    }
                    break;

                default:
                    Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                    break;
                }
            }

            if (string.IsNullOrEmpty(publishInfo.MenuPath))
            {
                if (visioContentType == VisioContentType.Template || visioContentType == VisioContentType.Stencil)
                {
                    Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "MenuPath"));
                }
            }

            if (publishInfo.VisioVersion == VisioVersion.Default)
            {
                publishInfo.VisioVersion = VisioPublishInfo.GetDefaultVisioVersion(fileName);
            }

            if (publishInfo.VisioEdition == VisioEdition.Default)
            {
                publishInfo.VisioEdition = (VisioEdition.X86 | VisioEdition.X64);
            }

            if ((publishInfo.VisioEdition & VisioEdition.X86) == VisioEdition.X86)
            {
                Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction", "UpdateConfigChangeID32");
            }

            if ((publishInfo.VisioEdition & VisioEdition.X64) == VisioEdition.X64)
            {
                Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction", "UpdateConfigChangeID64");
            }

            if (Core.EncounteredError)
            {
                return;
            }

            var featureId   = feature ?? Guid.Empty.ToString("B");
            var componentId = component ?? contextComponentId;

            foreach (var rowInfo in publishInfo.GenerateRowInfos(visioContentType, fileName))
            {
                var row = Core.CreateRow(sourceLineNumbers, "PublishComponent");

                row[0] = rowInfo.VisioComponentId;
                row[1] = rowInfo.Qualifier;
                row[2] = componentId;
                row[3] = rowInfo.AppData;
                row[4] = featureId;
            }
        }