Example #1
0
        /// <summary>
        /// Returns an invisible BoundingBox that defines a container in which
        /// all shapes fall within its boundary.
        /// </summary>
        /// <param name="page">Page with shapes to get a BoundingBox around.</param>
        /// <returns>A BoundingBox.</returns>
        public static BoundingBox getBoundingBox(Visio.Page page)
        {
            BoundingBox box = new BoundingBox(0.0, 0.0, 0.0, 0.0);

            // Get all shapes on the page
            Visio.Shapes allShapes = page.Shapes;

            // Iterate through all Shapes, get the most upper left and most lower
            // right Shape and use its coordinates to define the BoundingBox
            int index = 0;

            foreach (Visio.Shape s in allShapes)
            {
                // Retrieves the PinX, PinY Cell values that holds the Shape's center coordinates
                double shapeX = s.Cells["PinX"].Result["inches"];
                double shapeY = s.Cells["PinY"].Result["inches"];

                // Get the shape's Width & Height and adds half of its value to the BoundingBox
                // to include the whole Shape in the Box (since we are using the Shape's CENTER)
                double halfShapeWidth  = s.Cells["Width"].Result["inches"] / 2;
                double halfShapeHeight = s.Cells["Height"].Result["inches"] / 2;

                // if it's the first shape, automatically set a BoundingBox around it as a starting point.
                if (index == 0)
                {
                    box.UpperLeftX  = shapeX - halfShapeWidth;
                    box.LowerRightX = shapeX + halfShapeWidth;
                    box.UpperLeftY  = shapeY + halfShapeHeight;
                    box.LowerRightY = shapeY - halfShapeHeight;
                }
                else
                {
                    if (shapeX < box.UpperLeftX)
                    {
                        // this shape is more left than the current BoundingBox left boundary.
                        box.UpperLeftX = shapeX - halfShapeWidth;
                    }
                    else if (shapeX > box.LowerRightX)
                    {
                        // this shape is more right than the current BoundingBox right boundary.
                        box.LowerRightX = shapeX + halfShapeWidth;
                    }

                    if (shapeY > box.UpperLeftY)
                    {
                        // this shape is higher than the current BoundingBox top boundary.
                        box.UpperLeftY = shapeY + halfShapeHeight;
                    }
                    else if (shapeY < box.LowerRightY)
                    {
                        // this shape is lower than the current BoundingBox bottom boundary.
                        box.LowerRightY = shapeY - halfShapeHeight;
                    }
                }

                ++index;
            }

            return(box);
        }
Example #2
0
        public void violationValidator(Visio.Shapes shapes, Visio.Document document, Visio.ValidationRuleSet violationValidatorRuleSet)
        {

            foreach(Visio.Shape shape in shapes)
            {
                if(shape.Master.Name == "Violation")
                {
                    var outgoingShapes = new List<Visio.Shape>();
                    Array outgoing1Dshapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                    if(outgoing1Dshapes.Length == 0)
                    {
                        // Issue Handling: Violation Event muss einen ausgehenden DangerFlow haben. (shape weil event markiert werden soll)
                        //customRule2.AddIssue(shape.ContainingPage, shape);
                        violationValidatorRuleSet.Rules.get_ItemFromID(2).AddIssue(shape.ContainingPage, shape);
                        continue;
                    }
                    foreach (Object element in outgoing1Dshapes)
                    {
                        outgoingShapes.Add(shapes.get_ItemFromID((int)element));
                    }
                    foreach(Visio.Shape element in outgoingShapes)
                    {
                        if(element.Master.Name != "DangerFlow")
                        {
                            //Issue Handling: Outgoing Flow ist kein DangerFlow (element weil Flow markiert werden soll)
                            //customRule1.AddIssue(shape.ContainingPage, element);
                            violationValidatorRuleSet.Rules.get_ItemFromID(1).AddIssue(shape.ContainingPage, element);
                        }
                    }
                }              
            }
        }
        public static IEnumerable <IVisio.Shape> AsEnumerable(this IVisio.Shapes shapes)
        {
            int count = shapes.Count;

            for (int i = 0; i < count; i++)
            {
                yield return(shapes[i + 1]);
            }
        }
Example #4
0
        public static List <IVisio.Shape> GetShapesFromIDs(IVisio.Shapes shapes, IList <short> shapeids)
        {
            var shape_objs = new List <IVisio.Shape>(shapeids.Count);

            foreach (short shapeid in shapeids)
            {
                var shape = shapes.ItemFromID16[shapeid];
                shape_objs.Add(shape);
            }
            return(shape_objs);
        }
Example #5
0
        /// <summary>
        /// Returns all the Shapes currently on the given Page.
        /// </summary>
        /// <param name="page">Page with the Shapes.</param>
        /// <returns>List of Shapes.</returns>
        public static List <Visio.Shape> getAllShapesOnPage(Visio.Page page)
        {
            List <Visio.Shape> shapesList = new List <Visio.Shape>();

            Visio.Shapes shapes = page.Shapes;
            foreach (Visio.Shape s in shapes)
            {
                shapesList.Add(s);
            }

            return(shapesList);
        }
Example #6
0
 public String[] getShapeNames(Visio.Shapes shapes)         //https://docs.microsoft.com/de-de/office/vba/api/visio.shapes.item
 {
     Visio.Shapes vsoShapes = shapes;
     int shapeCount = vsoShapes.Count;
     string[] names = new string[shapeCount];
     if (shapeCount > 0)
     {
         for (int i = 1; i < shapeCount; i++)
         {
             names[i - 1] = vsoShapes.get_ItemU(i).Name;
         }
     }
     return names;
 }
Example #7
0
        public void executeThisAddIn(Visio.Document doc)
        {
            // TODO: executeThisAddIn wird beim Öffnen eines Dokuments 3 Mal ausgeführt. Temporary fix mit Boolean insertedRuleSet
            if (insertedRuleSet == false)
            {
                insertRuleSets(doc);
                insertedRuleSet = true;

                //Reihenfolge an Regeln nicht verändern!
                Visio.Shapes vsoShapes = getShapesFromPage();

                //When Microsoft Visio performs validation, it fires a RuleSetValidated event for every rule set that it processes, even if a rule set is empty.
                Application.RuleSetValidated += new Visio.EApplication_RuleSetValidatedEventHandler(HandleRuleSetValidatedEvent);
            }
        }
Example #8
0
        public static void printProperties(Visio.Shapes shapes)
        {
            string res = "";

            // Look at each shape in the collection.
            foreach (Visio.Shape shape in shapes)
            {
                // Use this index to look at each row in the properties
                // section.
                short iRow = (short)Visio.VisRowIndices.visRowFirst;

                // While there are stil rows to look at.
                while (shape.get_CellsSRCExists(
                           (short)Visio.VisSectionIndices.visSectionProp,
                           iRow,
                           (short)Visio.VisCellIndices.visCustPropsValue,
                           (short)0) != 0)
                {
                    // Get the label and value of the current property.
                    string label = shape.get_CellsSRC(
                        (short)Visio.VisSectionIndices.visSectionProp,
                        iRow,
                        (short)Visio.VisCellIndices.visCustPropsLabel
                        ).get_ResultStr(Visio.VisUnitCodes.visNoCast);

                    string value = shape.get_CellsSRC(
                        (short)Visio.VisSectionIndices.visSectionProp,
                        iRow,
                        (short)Visio.VisCellIndices.visCustPropsValue
                        ).get_ResultStr(Visio.VisUnitCodes.visNoCast);

                    // Print the results.
                    res += (string.Format(
                                "Shape={0} Label={1} Value={2}\r\n",
                                shape.Name, label, value));

                    // Move to the next row in the properties section.
                    iRow++;
                }

                // Now look at child shapes in the collection.
                if (shape.Master == null && shape.Shapes.Count > 0)
                {
                    printProperties(shape.Shapes);
                }
            }
            MessageBox.Show(res);
        }
Example #9
0
        /// <summary>
        /// Converts a Transform-Center Diagram to an Architectural Chart.
        /// </summary>
        private void transformToArchChart(Visio.Page inputPage, Visio.Page outputPage, Visio.Shape root)
        {
            // Separates a Transform-Center into its different components
            // ie. a Process tree, an Input tree, and an Output tree. To get all these
            // components, start at the Root and retrieve all Shapes connected to Root.

            // Gets all shapes that are connected to the root shape through a connector
            // (such as through a 1-D Dynamic Connector)
            List <int> shapeIDs = new List <int>(
                (int[])root.ConnectedShapes(Visio.VisConnectedShapesFlags.visConnectedShapesAllNodes, ""));

            // Gets all shapes that are glued to the root shape (as in, it is connected
            // directly to the root shape.
            shapeIDs.AddRange(
                (int[])root.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesAll1D, ""));

            List <Visio.Shape> inputs  = new List <Visio.Shape>();
            List <Visio.Shape> process = new List <Visio.Shape>();
            List <Visio.Shape> outputs = new List <Visio.Shape>();

            Visio.Shapes allShapes = inputPage.Shapes;

            foreach (int id in shapeIDs)
            {
                Visio.Shape toShape = allShapes.get_ItemFromID(id);

                if (toShape.Master.Name == CaseTypes.TRANSFORM_PROCESS_MASTER)
                {
                    process.Add(toShape);
                }
                else if (toShape.Master.Name == CaseTypes.TRANSFORM_INPUT_MASTER)
                {
                    inputs.Add(toShape);
                }
                else if (toShape.Master.Name == CaseTypes.TRANSFORM_OUTPUT_MASTER)
                {
                    outputs.Add(toShape);
                }
            }

            // Draws the Architecture Chart on the Architecture Chart Page.
            outputChart(outputPage, root, inputs, process, outputs);
        }
Example #10
0
        public void CIAValidator(Visio.Shapes shapes, Visio.Document document, Visio.ValidationRuleSet ciaValidatorRuleSet)
        {

            var informationSecurityShapes = new List<String>();
            informationSecurityShapes.Add("Confidentiality");
            informationSecurityShapes.Add("Integrity");
            informationSecurityShapes.Add("Availability");
            var informationShapes = new List<String>();
            informationShapes.Add("Datenobjekt");
            informationShapes.Add("Nachricht");
            informationShapes.Add("Datenspeicher");
            foreach (Visio.Shape shape in shapes)
            {
                if (informationSecurityShapes.Contains(shape.Master.Name))
                {   
                    if(shape.Master.Name == "Availability")
                    {
                        Boolean gluedToNonDataObject = false;
                        var gluedShapes1 = new List<Visio.Shape>();
                        Array allGlued1Shapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesAll2D, "");
                        foreach (Object element in allGlued1Shapes)
                        {
                            gluedShapes1.Add(shapes.get_ItemFromID((int)element));
                        }
                        foreach (Visio.Shape element in gluedShapes1)
                        {
                            if (!informationShapes.Contains(element.Master.Name))
                            {
                                gluedToNonDataObject = true;
                            }
                        }
                        if (gluedToNonDataObject == true)
                        {
                            var outgoingFlows = new List<Visio.Shape>();
                            Array outgoing1D = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                            foreach (Object element in outgoing1D)
                            {
                                outgoingFlows.Add(shapes.get_ItemFromID((int)element));
                            }
                            foreach(Visio.Shape x in outgoingFlows)
                            {
                                if(x.Master.Name != "Nachrichtenfluss")
                                {
                                    //Issue Handling: Ausgehender Fluss muss Nachrichtenfluss sein
                                    //customRule1.AddIssue(shape.ContainingPage, shape);
                                    ciaValidatorRuleSet.Rules[1].AddIssue(shape.ContainingPage, shape);
                                }
                            }
                            if (!outgoingFlows.Any())
                            {
                                //Issue Handling: Braucht ausgehenden Nachrichtenfluss
                                //customRule1.AddIssue(shape.ContainingPage, shape);
                                ciaValidatorRuleSet.Rules[1].AddIssue(shape.ContainingPage, shape);
                            }
                            return;
                        }
                    }
                    var gluedShapes = new List<Visio.Shape>();
                    Array allGluedShapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesAll2D, "");
                    if(allGluedShapes.Length == 0)
                    {
                        // Issue Handling: Data-Security Element muss an ein Data-Shape geklebt werden.
                        ciaValidatorRuleSet.Rules[2].AddIssue(shape.ContainingPage, shape);
                        continue;
                    }
                    foreach (Object element in allGluedShapes)
                    {
                        gluedShapes.Add(shapes.get_ItemFromID((int)element));
                    }
                    foreach(Visio.Shape element in gluedShapes)
                    {
                        if (!informationShapes.Contains(element.Master.Name))
                        {
                            //Issue Handing: Information Security Shape muss an ein Daten-Shapen geklebt werden.
                            //customRule2.AddIssue(shape.ContainingPage, shape);
                            ciaValidatorRuleSet.Rules[2].AddIssue(shape.ContainingPage, shape);
                        }
                    }
                }
            }
        }
Example #11
0
 public static List <IVisio.Shape> ToList(this IVisio.Shapes shapes)
 {
     return(ExtensionHelpers.ToList(() => shapes.Count, i => shapes[i + 1]));
 }
Example #12
0
 public static IEnumerable <IVisio.Shape> ToEnumerable(this IVisio.Shapes shapes)
 {
     return(ExtensionHelpers.ToEnumerable(() => shapes.Count, i => shapes[i + 1]));
 }
Example #13
0
 public RenderContext(IVisio.Page visio_page)
 {
     this._id_to_shape = new Dictionary <short, IVisio.Shape>();
     this.VisioPage    = visio_page;
     this._pageshapes  = visio_page.Shapes;
 }
Example #14
0
 public static IEnumerable <IVisio.Shape> ToEnumerable(this IVisio.Shapes shapes)
 {
     return(Shapes.ShapeHelper.ToEnumerable(shapes));
 }
Example #15
0
 public static IEnumerable <IVisio.Shape> ToEnumerable(this IVisio.Shapes shapes)
 {
     return(VisioAutomation.Internal.Extensions.ExtensionHelpers.ToEnumerable(() => shapes.Count, i => shapes[i + 1]));
 }
Example #16
0
 public static List <IVisio.Shape> ToList(this IVisio.Shapes shapes)
 {
     return(VisioAutomation.Internal.Extensions.ExtensionHelpers.ToList(() => shapes.Count, i => shapes[i + 1]));
 }
Example #17
0
        public void EntrypointValidator(Visio.Shapes shapes, Visio.Document document, Visio.ValidationRuleSet entrypointValidatorRuleSet)
        {

            // Laufe über alle Shapes des Dokuments
            foreach(Visio.Shape shape in shapes)
            {
                //prüfe zunächst ob alle PerimeterBarriers in einem Container ist
                if (shape.Master.Name == "PerimeterBarrier")
                {
                    if (shape.MemberOfContainers.Length == 0)
                    {
                        // Issue Handling: PerimeterBarrier außerhalb aller Container
                        entrypointValidatorRuleSet.Rules[5].AddIssue(shape.ContainingPage, shape);
                    }
                }
                if (shape.Master.Name == "EntryPoint") //Für jeden EntryPoint im Dokument
                {
                    // Listen für auf den EntryPoint folgende Shapes
                    var out1DShapeList = new List<Visio.Shape>();
                    var out2DShapeList = new List<Visio.Shape>();
                    // Listen für dem EntryPoint vorhergehenden Shapes
                    var in1DShapeList = new List<Visio.Shape>();
                    var in2DShapeList = new List<Visio.Shape>();
                    // Liste für Container Objecte
                    var containerShapes = new List<Visio.Shape>();
                    var containerMembers = new List<Visio.Shape>();
                    Boolean inGroup = false;

                    //Es wird davon ausgegangen, dass EntryPoint immer mit nur einem outgoing Sequenzfluss (bzw. D.F.) verbunden ist
                    //zusätzlich kann ein EntryPoint aber  noch mit einem MessageFlow verbunden sein
                    //prüfe alle outgoing 1D shapes (Pfeile: Sequenzfluss, DangerFlow, MSgFlow)
                    Array out1DArray = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                    if(out1DArray.Length == 0)
                    {
                        // Issue Handling: EntryPoint has to have an outgoing Flow
                        //customRule1.AddIssue(shape.ContainingPage, shape);
                        entrypointValidatorRuleSet.Rules[1].AddIssue(shape.ContainingPage, shape);
                        continue;
                    }
                    //Array in Liste mit den out 1D shapes casten
                    foreach (Object element in out1DArray)
                    {
                        out1DShapeList.Add(shapes.get_ItemFromID((int)element));
                    }
                    // Über alle outgoing Flows laufen
                    foreach(Visio.Shape outFlow in out1DShapeList)
                    {
                        if(outFlow.Master.Name == "DangerFlow" || outFlow.Master.Name == "Sequenzfluss")
                        {
                            Array out2DArray = outFlow.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing2D, ""); //an den Fluss gebundenen outgoing 2D shapes
                                                                                                                            //Es wird davon ausgegangen, dass nur ein outgoing 2D Shape an einen Flow gebunden ist

                            if (out2DArray.Length == 0) //wenn kein zweites Element an den Fluss gebunden ist
                            {
                                // Issue Handling: Sequenzfluss braucht vorangehendes Element
                                entrypointValidatorRuleSet.Rules[6].AddIssue(outFlow.ContainingPage, outFlow);
                            }
                            foreach (Object element in out2DArray)
                            {
                                out2DShapeList.Add(shapes.get_ItemFromID((int)element)); // in Liste mit den out 2D shapes casten
                            }
                            foreach(Visio.Shape out2DShape in out2DShapeList) //laufe über alle out 2D shapes (nur eins)
                            {
                                //ist das out2DShape Teil eines Gruppen-containers
                                Array containerIDs = out2DShape.MemberOfContainers; //Holt alle Container in denen das 2D Shape enthalten ist
                                foreach (Object element in containerIDs)
                                {
                                    containerShapes.Add(shapes.get_ItemFromID((int)element)); //Castet Container IDs in Liste mit Container Objekten
                                }
                                foreach(Visio.Shape container in containerShapes)
                                {
                                    //true wenn 2D shape Teil eines Gruppen container ist --> Issue Handling wenn 2D shape nicht Teil einer Gruppe ist (alle zugeordneten Container dürfen keine Gruppe sein)
                                    if(container.Master.NameU == "Group")
                                    {
                                        inGroup = true;
                                        //hole alle Shapes die Teil des Gruppen Containers sind
                                        Array memberShapes = container.ContainerProperties.GetMemberShapes(0); // Array "with all shape types and including items in nested containers"
                                        foreach(Object element in memberShapes) //kann nicht leer sein, da mind. out2DShape enthalten sein muss
                                        {
                                            containerMembers.Add(shapes.get_ItemFromID((int)element)); //in Liste mit allen Shapes auf dem Container casten
                                        }
                                        foreach(Visio.Shape memberShape in containerMembers) //prüfe alle Mitglieder des Gruppen containers
                                        {
                                            //wenn PreimeterBarrier enthalten -> Sicherheitsbereich -> Identifikation vor EntryPoint
                                            if (memberShape.Master.Name == "PerimeterBarrier") 
                                            {
                                                Array in1DArray = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesIncoming1D,"");
                                                if(in1DArray.Length == 0)
                                                {
                                                    // Issue Handling: EntryPoint benötigt einen Incoming Flow; Muss nach einem Identifikationselement stehen
                                                    //customRule2.AddIssue(shape.ContainingPage, shape);
                                                    entrypointValidatorRuleSet.Rules[2].AddIssue(shape.ContainingPage, shape);
                                                }
                                                // In Liste mit in 1D Shapes casten
                                                foreach(Object element in in1DArray)
                                                {
                                                    in1DShapeList.Add(shapes.get_ItemFromID((int)element)); //es wird davon ausgegangen dass nur ein Element enthalten ist
                                                }
                                                //Laufe über alle incoming Flows (nur einer)
                                                foreach(Visio.Shape inFlow in in1DShapeList)
                                                {
                                                    Array in2DArray = inFlow.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesIncoming2D, "");
                                                    if (in2DArray.Length == 0)
                                                    {
                                                        // Issue Handling: Sequenzfluss braucht vorangehendes Element
                                                        entrypointValidatorRuleSet.Rules[6].AddIssue(inFlow.ContainingPage, inFlow);
                                                    }
                                                    //In Liste mit allen 2D Shapes casten --> Liste enthält das 2D Shape welchses sich vor dem EntryPoint befindet
                                                    foreach(Object element in in2DArray)
                                                    {
                                                        in2DShapeList.Add(shapes.get_ItemFromID((int)element));
                                                    }
                                                    //prüfe vor vorangehendes Element eine Identifikation ist
                                                    foreach(Visio.Shape in2DShape in in2DShapeList)
                                                    {
                                                        if(in2DShape.Master.Name != "Identification")
                                                        {
                                                            // Issue Handling: Wenn EntryPoint vor einem Schutzbereich steht, muss vor dem EntryPoint eine Identifikation statt finden
                                                            //customRule3.AddIssue(shape.ContainingPage, shape);
                                                            entrypointValidatorRuleSet.Rules[3].AddIssue(shape.ContainingPage, shape);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if(inGroup == false)
                                {
                                    // Issue Handling: out 2D shape ist nicht Teil einer Gruppe
                                    //customRule4.AddIssue(out2DShape.ContainingPage, out2DShape);
                                    entrypointValidatorRuleSet.Rules[4].AddIssue(shape.ContainingPage, shape);
                                }
                            }
                        }
                    }
                }
            }
        }
 public static IList <IVisio.Shape> GetShapesFromIDs(this IVisio.Shapes shapes, IList <short> shapeids)
 {
     return(Shapes.ShapeHelper.GetShapesFromIDs(shapes, shapeids));
 }
Example #19
0
        public void surveillanceValidator(Visio.Shapes shapes, Visio.Document document, Visio.ValidationRuleSet surveillanceValidatorRuleSet)
        {

            var surveillanceShapes = new List<String>();
            surveillanceShapes.Add("SecurityGuard");
            surveillanceShapes.Add("CCTV");
            surveillanceShapes.Add("AlarmSystem");
            surveillanceShapes.Add("SecurityGuardTask.54"); //kp warum der Master so heißt

            foreach (Visio.Shape shape in shapes)
            {
                if (surveillanceShapes.Contains(shape.Master.Name))
                {
                    var containerShapes = new List<Visio.Shape>();
                    Boolean inGroup = false;
                    //Prüft ob es sich um die S.G._Task handelt
                    if (shape.Master.Name == "SecurityGuardTask.54")
                    {
                        // holt alle Flows von dem S.G._Task
                        var outgoingShapes = new List<Visio.Shape>();
                        Array outgoing1Dshapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                        foreach (Object element in outgoing1Dshapes)
                        {
                            outgoingShapes.Add(shapes.get_ItemFromID((int)element));
                        }
                        Boolean hasMsgFlow = false;
                        foreach(Visio.Shape outFlow in outgoingShapes)
                        {
                            if(outFlow.Master.Name == "Nachrichtenfluss")
                            {
                                hasMsgFlow = true;
                            }
                        }
                        if(hasMsgFlow == false)
                        {
                            // Issue Handling: No outgoing Message Flow bei der SecurityGuardTask (Regel 4 [13])
                            surveillanceValidatorRuleSet.Rules[4].AddIssue(shape.ContainingPage, shape);
                        }
                        continue; //shape von weiterer Bearbeitung ausschließen
                    }
                    //Prüft ob dem Shape ein Container zugeordnet ist, wenn nicht: Verstoß gegen Modellierungsregel 1
                    if(shape.MemberOfContainers.Length == 0){
                        //customRule1.AddIssue(shape.ContainingPage, shape);
                        surveillanceValidatorRuleSet.Rules[1].AddIssue(shape.ContainingPage, shape);
                    }
                    else{
                        //Holt alle Container Objekte in denen das aktuelle Shape liegt; Fügt sie der Liste containerIDs hinzu
                        Array containerIDs = shape.MemberOfContainers;
                        foreach(Object element in containerIDs){
                            containerShapes.Add(shapes.get_ItemFromID((int)element));
                        }
                        foreach(Visio.Shape container in containerShapes){
                            if(container.Master.NameU == "Group"){
                                var outgoingShapes = new List<Visio.Shape>();
                                Array outgoing1Dshapes = container.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                                foreach (Object element in outgoing1Dshapes)
                                {
                                    outgoingShapes.Add(shapes.get_ItemFromID((int)element));
                                }
                                if (!outgoingShapes.Any())
                                {
                                    // Issue Handling: Kein outgoing Message Flow an dem überwachten Group-Shape
                                    //customRule2.AddIssue(shape.ContainingPage, shape);
                                    surveillanceValidatorRuleSet.Rules[2].AddIssue(shape.ContainingPage, shape);
                                }
                                inGroup = true;
                                break;
                            }
                        }
                        //Surveillance Shape in einer Lane/in einem Pool.
                        if (inGroup == false)
                        {
                            foreach (Visio.Shape container in containerShapes)
                            {
                                if (container.Master.NameU == "Swimlane List")
                                {
                                    var cffOfCont = new List<Visio.Shape>();
                                    Array cont = container.MemberOfContainers;
                                    // erstellt eine Liste mit den CFF containern des Swimlane List containers (hoffentlich immer nur einer) ->Funktioniert das?
                                    // die Konnektoren hängen nur an den CFF-Containern: der CFF-Container beinhaltet eine "Swimlane List" und eine "Phasen List" (Container Elemente "Pool/Lane" dafür nicht nutzbar warum auch immer)
                                    foreach(Object element in cont)
                                    {
                                        if(shapes.get_ItemFromID((int)element).Master.Name == "CFF-Container")
                                        {
                                            cffOfCont.Add(shapes.get_ItemFromID((int)element));
                                        }
                                    }
                                    //Überspringt wahrscheinlich die schleife --> If abfrage??
                                    foreach (Visio.Shape cff in cffOfCont)
                                    {
                                        var outgoingShapes = new List<Visio.Shape>();
                                        Array outgoing1Dshapes = cff.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                                        foreach (Object element in outgoing1Dshapes)
                                        {
                                            outgoingShapes.Add(shapes.get_ItemFromID((int)element));
                                        }
                                        //hat der cff container outgoing 1D shapes?
                                        if (!outgoingShapes.Any())
                                        {
                                            // Issue Handling: Kein outgoing Message Flow an dem überwachten Lane-Shape
                                            //customRule3.AddIssue(shape.ContainingPage, shape);
                                            surveillanceValidatorRuleSet.Rules[3].AddIssue(shape.ContainingPage, shape);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #20
0
        public void gatewayValidator(Visio.Shapes shapes, Visio.Document document, Visio.ValidationRuleSet gatewayValidatorRuleSet)
        {

            foreach (Visio.Shape shape in shapes)
            {
                if(shape.Master.NameU == "Gateway")
                {
                    Boolean mixedFlows = false;
                    var incomingShapes = new List<Visio.Shape>();
                    var outgoingShapes = new List<Visio.Shape>();
                    Array incoming1Dshapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesIncoming1D, "");
                    Array outgoing1Dshapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                    if(incoming1Dshapes.Length == 0)
                    {
                        //Issue Handling    Keine eingehenden Flows
                        gatewayValidatorRuleSet.Rules[3].AddIssue(shape.ContainingPage, shape);
                        continue;
                    }
                    if(outgoing1Dshapes.Length == 0)
                    {
                        //Issue Handling    Keine ausgehenden Flows
                        gatewayValidatorRuleSet.Rules[3].AddIssue(shape.ContainingPage, shape);
                        continue;
                    }
                    foreach (Object element in incoming1Dshapes)
                    {
                        incomingShapes.Add(shapes.get_ItemFromID((int)element));
                    }
                    foreach (Object element in outgoing1Dshapes)
                    {
                        outgoingShapes.Add(shapes.get_ItemFromID((int)element));
                    }

                    String comparisonShape = incomingShapes.First().Master.Name;
                    foreach (Visio.Shape current in incomingShapes)
                    {
                        if(current.Master.Name != comparisonShape)
                        {   //Wenn ungleiche Sequenzflüsse zusammengeführt werden, müssen ausgehende Sequenzflüsse DangerFlows sein.
                            mixedFlows = true;
                            foreach(Visio.Shape x in outgoingShapes)
                            {
                                if(x.Master.Name != "DangerFlow")
                                {
                                    //customRule1.AddIssue(x.ContainingPage, x);
                                    gatewayValidatorRuleSet.Rules[1].AddIssue(shape.ContainingPage, x);
                                }
                            }
                            break;                           
                        }
                    }
                    //Alle eingehenden Sequenzflüsse sind gleich, aber mindestens ein ausgehender Sequenzfluss ist ungleich.
                    if(mixedFlows == false)
                    {
                        foreach(Visio.Shape element in outgoingShapes)
                        {
                            if(element.Master.Name != comparisonShape)
                            {
                                //customRule2.AddIssue(element.ContainingPage, element);
                                gatewayValidatorRuleSet.Rules[2].AddIssue(shape.ContainingPage, element);
                            }
                        }
                    }
                }
            }
        }
Example #21
0
        public void inspectionValidator(Visio.Shapes shapes, Visio.Document document, Visio.ValidationRuleSet inspectionValidatorRuleSet)
        {
            // TODO: Dynamisch codieren, dass es nur einen outgoing sequence flow geben darf.

            //int count = 0;
            foreach(Visio.Shape shape in shapes)
            {
                if(shape.Master.Name == "Inspection")
                {
                    int count = 0;
                    var gluedShapesIDs = new List<int>();
                    if (shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "").Length > 1)
                    {
                        //Issue Handling: Missing Outgoing Sequence Flow for secure case distinction
                        var outgoingShapes = new List<Visio.Shape>();
                        Array outgoing1Dshapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");
                        int seqFlows = 0;
                        foreach (Object element in outgoing1Dshapes)
                        {
                            outgoingShapes.Add(shapes.get_ItemFromID((int)element));
                        }
                        foreach(Visio.Shape flow in outgoingShapes)
                        {
                            if(flow.Master.NameU == "Sequence Flow")
                            {
                                seqFlows++;
                            }
                        }
                        if (seqFlows != 1)
                        {
                            inspectionValidatorRuleSet.Rules[1].AddIssue(shape.ContainingPage, shape);
                        }
                    }



                    Array glued2Dshapes = shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesAll2D, ""); 
                    foreach(Object element in glued2Dshapes){
                        gluedShapesIDs.Add((int)element);
                    }
                    if (!gluedShapesIDs.Any())  
                    {
                        inspectionValidatorRuleSet.Rules[2].AddIssue(shape.ContainingPage, shape); // Issue Handling: Keine glued 2D Shapes vorhanden
                        break;
                    }
                    else
                    {
                        foreach(int id in gluedShapesIDs)
                        {
                            if (shapes.get_ItemFromID(id).Master.Name == "Violation")
                            {
                                count++;
                            }
                        }
                        if (count== 0)
                        {
                            inspectionValidatorRuleSet.Rules[3].AddIssue(shape.ContainingPage, shape); // Issue Handling: Keine "Violation"-Shape an das Inspection-Shape geklebt.
                        }
                    }
                }
            }
        }
 public RenderContext(IVisio.Page visio_page)
 {
     this.id_to_shape = new Dictionary<short, IVisio.Shape>();
     this.VisioPage = visio_page;
     this.pageshapes = visio_page.Shapes;
 }
Example #23
0
        /// <summary>
        /// Builds a State Machine from a State Transition Diagram, starting at the given node.
        /// </summary>
        /// <param name="node">A starting node in the State Transition Diagram.</param>
        /// <returns>The State Machine, in the form of a list of States.</returns>
        private List <State> buildStateMachine(Visio.Shape node)
        {
            Visio.Shapes allShapesOnPage = node.ContainingPage.Shapes;

            List <State> stateMachine = new List <State>();

            // Lists the corresponding Shape for each State in the StateMachine list.
            List <Visio.Shape> stateShapes = new List <Visio.Shape>();

            // For each node, create a State for it (if it doesn't already exist)
            // & adds the State to the stateMachine (if it isn't already in the list).
            // Each node is connected to other nodes via a connector.
            bool notDone           = true;
            int  currentStateIndex = 0;

            while (notDone)
            {
                // if current state is not part of the state machine, add it
                string currentStateName = node.Text;
                State  currentState     = stateExists(stateMachine, currentStateName);
                if (currentState == null)
                {
                    currentState = new State(currentStateName, node.Master.Name);
                    stateMachine.Add(currentState);
                    stateShapes.Add(node);
                }

                // for the current state, get all transitions to its next state
                int[] transitions = (int[])node.GluedShapes(
                    Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "");

                // each transition leads to a next state
                foreach (int t in transitions)
                {
                    Visio.Shape connector   = allShapesOnPage.get_ItemFromID(t);
                    int[]       nextStateID = (int[])connector.GluedShapes(
                        Visio.VisGluedShapesFlags.visGluedShapesOutgoing2D, "");

                    // there's only one shape connected to one end of a 1-D connector,
                    // but it could be a shape that's already been made into a State
                    Visio.Shape nextStateShape = allShapesOnPage.get_ItemFromID(nextStateID[0]);
                    string      nextStateName  = nextStateShape.Text;
                    State       nextState      = stateExists(stateMachine, nextStateName);
                    if (nextState == null)
                    {
                        nextState = new State(nextStateName, nextStateShape.Master.Name);
                        stateMachine.Add(nextState);
                        stateShapes.Add(nextStateShape);
                    }

                    // assumes that a Connector always has two data associated with it
                    // separated by a ','
                    string[] connectorData = connector.Text.Split(',');
                    currentState.addNextState(connectorData[0], connectorData[1], nextState);
                }

                // Needs to get states that lead to this state, else depending on the
                // starting state, won't be able to reach all states if we use just
                // next state transitions. Ex: starting at the End State, there are no
                // transitions that leads to another state & so won't be able to find
                // what other states are in the system.

                // for the current state, get all transitions that led to this state
                int[] backTransitions = (int[])node.GluedShapes(
                    Visio.VisGluedShapesFlags.visGluedShapesIncoming1D, "");

                // each backTransition points to a previous state
                foreach (int t in backTransitions)
                {
                    Visio.Shape connector   = allShapesOnPage.get_ItemFromID(t);
                    int[]       prevStateID = (int[])connector.GluedShapes(
                        Visio.VisGluedShapesFlags.visGluedShapesIncoming2D, "");

                    // there's only one shape connected to one end of a 1-D connector,
                    // but it could be a shape that's already been made into a State
                    Visio.Shape prevStateShape = allShapesOnPage.get_ItemFromID(prevStateID[0]);
                    string      prevStateName  = prevStateShape.Text;
                    State       prevState      = stateExists(stateMachine, prevStateName);
                    if (prevState == null)
                    {
                        prevState = new State(prevStateName, prevStateShape.Master.Name);
                        stateMachine.Add(prevState);
                        stateShapes.Add(prevStateShape);
                    }
                }

                ++currentStateIndex;

                // done if there are no more States to check in the StateMachine.
                if (currentStateIndex >= stateMachine.Count)
                {
                    notDone = false;
                }
                else
                {
                    node = stateShapes[currentStateIndex];
                }
            }

            return(stateMachine);
        }