Ejemplo n.º 1
0
        public override AnnotationInfo AnnotateWord()
        {
            // init possible types of annotations
            AnnotationInfo textReplacementAnnotation = InitAnnotationInfo();

            return(textReplacementAnnotation);
        }
        public override AnnotationInfo AnnotateDiagram()
        {
            AnnotationInfo polylineAnnotation = InitAnnotationInfo();

            fillCreatorName(polylineAnnotation);
            return(polylineAnnotation);
        }
Ejemplo n.º 3
0
        private void ExtractAnnotationInfo()
        {
            var annotatable = d_object as Cdn.Annotatable;

            if (annotatable != null && !String.IsNullOrEmpty(annotatable.Annotation))
            {
                d_annotationInfo = annotatable.ParseAnnotation();

                if (!String.IsNullOrEmpty(d_annotationInfo.RelativeTo))
                {
                    var node = d_object as Cdn.Node;

                    if (node == null)
                    {
                        node = d_object.Parent;
                    }

                    if (node != null)
                    {
                        d_annotationRelative = new List <Cdn.Object>(node.FindObjects(d_annotationInfo.RelativeTo));
                    }
                }
            }
            else
            {
                d_annotationInfo     = null;
                d_annotationRelative = new List <Cdn.Object>();
            }
        }
        public override AnnotationInfo AnnotateDiagram()
        {
            // init annotation object
            AnnotationInfo resourceRedactionAnnotation = InitAnnotationInfo();

            return(resourceRedactionAnnotation);
        }
        public CreateAnnotationResult CreateAnnotation(string documentGuid, AnnotationType type, Rectangle box,
            Point? annotationPosition,
            Range? textRange = null,
            string svgPath = null, string message = null)
        {
            Throw.IfNull<string>(documentGuid, "documentGuid");

            var template = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.CreateAnnotation);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "fileId", documentGuid }
            };

            var annotation = new AnnotationInfo { Type = type, Box = box, AnnotationPosition = annotationPosition, TextRange = textRange, SvgPath = svgPath };

            if (!String.IsNullOrWhiteSpace(message))
            {
                annotation.Replies = new AnnotationReplyInfo[] { new AnnotationReplyInfo { Message = message ?? "" } };
            }

            using (var content = HttpContentNetExtensions.CreateJsonNetDataContract<AnnotationInfo>(annotation))
            {
                var response = SubmitRequest<CreateAnnotationResponse>(template, parameters, "POST", content);
                if (response.Code != ResponseCode.Ok)
                {
                    throw new GroupdocsServiceException(response.ErrorMessage);
                }

                return response.Result;
            }
        }
        /// <summary>
        /// Removes all annotations in words document
        /// </summary>



        /// <summary>
        /// Add text annotation in cells
        /// </summary>
        /// Update CommonUtilities.filePath with path to Cells file before using this function
        public static void AddTextAnnotationInCells()
        {
            try
            {
                //ExStart:AddTextAnnotationInCells
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Initialize text annotation.
                AnnotationInfo textAnnotation = new AnnotationInfo
                {
                    PageNumber         = 1,
                    AnnotationPosition = new Point(3, 3),
                    FieldText          = "Hello!"
                };

                // Add annotation to list
                annotations.Add(textAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Cells);
                //ExEnd:AddTextAnnotationInCells
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 7
0
        public ActionResult Post(string file)
        {
            Response.AddHeader("Content-Type", "application/json");
            AnnotationImageHandler imageHandler        = Utils.createAnnotationImageHandler();
            IDocumentDataHandler   documentDataHandler = imageHandler.GetDocumentDataHandler();

            String   filename   = file;
            Document doc        = documentDataHandler.GetDocument(filename);
            long     documentId = doc != null ? doc.Id : imageHandler.CreateDocument(filename);

            //StreamReader stream = new StreamReader(Request.InputStream);
            //string x = stream.ReadToEnd();  // added to view content of input stream

            AnnotationInfo annotation = new AnnotationInfo(); //Request.InputStream as AnnotationInfo;

            annotation.DocumentGuid = documentId;
            CreateAnnotationResult result = imageHandler.CreateAnnotation(annotation);

            return(Content(JsonConvert.SerializeObject(
                               result,
                               Formatting.Indented,
                               new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            }
                               ), "application/json"));
        }
Ejemplo n.º 8
0
        public override AnnotationInfo AnnotateSlides()
        {
            // init possible types of annotations
            AnnotationInfo watermarkAnnotation = InitAnnotationInfo();

            return(watermarkAnnotation);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Shows how to add Ellipse Annotation in Images
        /// </summary>
        public static void AddEllipseAnnotationInImages()
        {
            try
            {
                //ExStart:AddEllipseAnnotationInImages
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Initialize ellipse annotation.
                AnnotationInfo ellipse = new AnnotationInfo
                {
                    Box  = new Rectangle(100, 100, 50, 50),
                    Type = AnnotationType.Ellipse
                };

                // Add annotation to list
                annotations.Add(ellipse);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddEllipseAnnotationInImages
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
        /// <summary>
        /// Adds area annotation with replies in Slides document
        /// </summary>
        public static void AddAreaAnnotationWithReplies()
        {
            try
            {
                //ExStart:AddAreaAnnotationWithReplies
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Area annotation with 2 replies
                AnnotationInfo areaAnnotation = new AnnotationInfo()
                {
                    CreatedOn          = DateTime.Now,
                    Type               = AnnotationType.Area,
                    PageNumber         = 0,
                    Box                = new Rectangle(100, 72.7f, 50, 50),
                    BackgroundColor    = -15988609,
                    AnnotationPosition = new Point(150, 150)
                };
                // Add annotation to list
                annotations.Add(areaAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Slides);
                //ExEnd:AddAreaAnnotationWithReplies
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds resource redaction annotation in Images document
        /// </summary>
        public static void AddResourceRedactionAnnotation()
        {
            try
            {
                //ExStart:AddResourceRedactionAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Resource redaction annotation
                AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 271.78),
                    BackgroundColor    = 3355443,
                    Box         = new Rectangle(466f, 271f, 69f, 62f),
                    PageNumber  = 0,
                    PenColor    = 3355443,
                    Type        = AnnotationType.ResourcesRedaction,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(resourceRedactionAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddResourceRedactionAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 12
0
        protected new AnnotationInfo InitAnnotationInfo()
        {
            AnnotationInfo textAnnotation = base.InitAnnotationInfo();

            textAnnotation.Guid = annotationData.id.ToString();
            return(textAnnotation);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds Polyline annotation in words document
        /// </summary>
        public static void AddPolylineAnnotationforWords()
        {
            try
            {
                //ExStart:AddPolylineAnnotationforWords
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);
                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Polyline annotation
                AnnotationInfo polylineAnnotation = new AnnotationInfo
                {
                    PageNumber = 0,
                    Type       = AnnotationType.Polyline,
                    Box        = new Rectangle(288.760559f, 533.7042f, 216.929581f, 171.676056f),
                    SvgPath    = "M504.9718309859155,678.0845070422536l-0.7183098591549296,0l-0.7183098591549296,0l-0.7183098591549296,0.7183098591549296l-0.7183098591549296,0.7183098591549296l-1.4366197183098592,0.7183098591549296l-2.154929577464789,2.154929577464789l-2.8732394366197185,0.7183098591549296l-5.028169014084507,2.154929577464789l-6.464788732394367,3.591549295774648l-10.774647887323944,3.591549295774648l-10.056338028169014,2.154929577464789l-9.338028169014084,2.154929577464789l-8.619718309859156,2.154929577464789l-9.338028169014084,3.591549295774648l-7.183098591549296,0l-7.183098591549296,0.7183098591549296l-5.028169014084507,0.7183098591549296l-5.746478873239437,1.4366197183098592l-5.746478873239437,0l-8.619718309859156,0l-12.211267605633804,0l-6.464788732394367,0l-8.619718309859156,-1.4366197183098592l-7.901408450704226,-3.591549295774648l-10.774647887323944,-5.746478873239437l-8.619718309859156,-5.028169014084507l-9.338028169014084,-5.746478873239437l-12.211267605633804,-9.338028169014084l-10.056338028169014,-10.056338028169014l-5.746478873239437,-7.901408450704226l-           6.464788732394367,-12.211267605633804l-2.154929577464789,-3.591549295774648l-5.028169014084507,-13.647887323943662l-2.154929577464789,-7.901408450704226l0,-7.183098591549296l0,-9.338028169014084l0,-5.746478873239437l2.8732394366197185,-7.901408450704226l5.028169014084507,-5.746478873239437l6.464788732394367,-7.183098591549296l10.774647887323944,-7.901408450704226l10.774647887323944,-6.464788732394367l15.084507042253522,-6.464788732394367l14.366197183098592,-6.464788732394367l22.267605633802816,-7.183098591549296l13.647887323943662,-3.591549295774648l14.366197183098592,-3.591549295774648l16.52112676056338,-0.7183098591549296l16.52112676056338,0l15.084507042253522,0l10.774647887323944,0l7.183098591549296,2.154929577464789l4.309859154929578,2.154929577464789l5.028169014084507,2.8732394366197185l3.591549295774648,2.154929577464789l3.591549295774648,2.8732394366197185l6.464788732394367,6.464788732394367l2.8732394366197185,4.309859154929578l2.154929577464789,2.154929577464789l2.154929577464789,4.309859154929578l1.4366197183098592,2.8732394366197185l2.154929577464789,5.028169014084507l0.7183098591549296,3.591549295774648l0.7183098591549296,5.028169014084507l0,5.028169014084507l0,4.309859154929578l0,7.183098591549296l-0.7183098591549296,2.8732394366197185l-3.591549295774648,6.464788732394367l-3.591549295774648,6.464788732394367l-4.309859154929578,5.028169014084507l-5.028169014084507,5.028169014084507l-7.183098591549296,4.309859154929578l-7.183098591549296,4.309859154929578l-10.774647887323944,6.464788732394367l-9.338028169014084,4.309859154929578l-9.338028169014084,4.309859154929578l-10.056338028169014,2.8732394366197185l-7.901408450704226,2.8732394366197185l-10.774647887323944,1.4366197183098592l-5.028169014084507,0.7183098591549296l-3.591549295774648,0l-2.8732394366197185,0l-3.591549295774648,0l-5.028169014084507,0l-5.746478873239437,0l-7.183098591549296,-1.4366197183098592l-5.746478873239437,-1.4366197183098592l-6.464788732394367,-2.8732394366197185l-4.309859154929578,-1.4366197183098592l-2.154929577464789,-1.4366197183098592l-1.4366197183098592,-0.7183098591549296l-1.4366197183098592,-0.7183098591549296l-0.7183098591549296,-0.7183098591549296l-1.4366197183098592,-1.4366197183098592l0,-0.7183098591549296l-1.4366197183098592,-0.7183098591549296l0,-1.4366197183098592l-0.7183098591549296,-0.7183098591549296l0,-0.7183098591549296",
                };
                // Add annotation to list
                annotations.Add(polylineAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Words);
                //ExEnd:AddPolylineAnnotationforWords
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 14
0
        public void XElementAnnotationTestFunctionImportParameterWithAnnotationModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation", 1);

            AnnotationInfo annotationInfo = new AnnotationInfo()
            {
                Namespace = "http://foo", Name = "Annotation"
            };

            List <ElementInfo> annotationPath = new List <ElementInfo>()
            {
                new ElementInfo()
                {
                    Name = "SimpleFunction", Type = AnnotatableElementType.Function
                },
                new ElementInfo()
                {
                    Name = "Name", Type = AnnotatableElementType.Parameter
                },
            };
            ElementLocation annotationLocation = new ElementLocation()
            {
                Namespace = "Default", ElementPath = annotationPath
            };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.ActionImportParameterWithAnnotationCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.OperationImportParameterWithAnnotationModel());
        }
Ejemplo n.º 15
0
        public override AnnotationInfo AnnotateImage()
        {
            // init possible types of annotations
            AnnotationInfo textAnnotation = InitAnnotationInfo();

            return(textAnnotation);
        }
Ejemplo n.º 16
0
        public void XElementAnnotationTestNavigationPropertyWithAnnotationModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation", 1);

            AnnotationInfo annotationInfo = new AnnotationInfo()
            {
                Namespace = "http://foo", Name = "Annotation"
            };

            List <ElementInfo> annotationPath = new List <ElementInfo>()
            {
                new ElementInfo()
                {
                    Name = "Person", Type = AnnotatableElementType.EntityType
                },
                new ElementInfo()
                {
                    Name = "Friends", Type = AnnotatableElementType.NavigationProperty
                }
            };
            ElementLocation annotationLocation = new ElementLocation()
            {
                Namespace = "DefaultNamespace", ElementPath = annotationPath
            };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.NavigationPropertyWithAnnotationCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.NavigationPropertyWithAnnotationModel());
        }
Ejemplo n.º 17
0
        public void AddAnnotationInfo(AnnotationInfo info, bool isReadOnly)
        {
            var newAnnot = Create(new Rect(info.TopLeft.X, info.TopLeft.Y, info.Width, info.Height), info.Comment, isReadOnly, info.RadiusX, info.RadiuxY);

            SetAnnotationDeselected(newAnnot);
            _Annotations.Add(newAnnot);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds underline annotation in Images document
        /// </summary>
        public static void AddUnderLineAnnotation()
        {
            try
            {
                //ExStart:AddUnderLineAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Underline annotation
                AnnotationInfo underlineAnnotation = new AnnotationInfo
                {
                    Box         = new Rectangle((float)248.57, (float)1135.78, (float)222.67, 27),
                    PageNumber  = 1,
                    SvgPath     = "[{\"x\":248.57,\"y\":503.507},{\"x\":471,\"y\":503.507},{\"x\":248.57,\"y\":468.9},{\"x\":471,\"y\":468.9}]",
                    Type        = AnnotationType.TextUnderline,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(underlineAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddUnderLineAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Adds text field annotation in Images document
        /// </summary>
        public static void AddTextFieldAnnotation()
        {
            try
            {
                //ExStart:AddTextFieldAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Text field annotation
                AnnotationInfo textFieldAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 201.0),
                    FieldText          = "text in the box",
                    FontFamily         = "Arial",
                    FontSize           = 10,
                    Box         = new Rectangle(66f, 201f, 64f, 37f),
                    PageNumber  = 0,
                    Type        = AnnotationType.TextField,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(textFieldAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddTextFieldAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 20
0
        public void XElementAnnotationTestAnnotationWithSchemaTagValueModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                             "</Schema>"
                             );

            AnnotationInfo annotationInfo = new AnnotationInfo()
            {
                Namespace = "http://foo", Name = "Annotation"
            };

            List <ElementInfo> annotationPath = new List <ElementInfo>()
            {
                new ElementInfo()
                {
                    Name = "SimpleType", Type = AnnotatableElementType.EntityType
                }
            };
            ElementLocation annotationLocation = new ElementLocation()
            {
                Namespace = "DefaultNamespace", ElementPath = annotationPath
            };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithSchemaTagValueCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.AnnotationWithSchemaTagValueModel());
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds text annotation in Images document
        /// </summary>
        public static void AddTextAnnotation()
        {
            try
            {
                //ExStart:AddTextAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Initialize text annotation.
                AnnotationInfo textAnnotation = new AnnotationInfo
                {
                    Box         = new Rectangle((float)265.44, (float)153.86, 206, 36),
                    PageNumber  = 1,
                    SvgPath     = "[{\"x\":265.44,\"y\":388.83},{\"x\":472.19,\"y\":388.83},{\"x\": 265.44,\"y\":349.14},{\"x\":472.19,\"y\":349.14}]",
                    Type        = AnnotationType.Text,
                    CreatorName = "Anonym A."
                };

                // Add annotation to list
                annotations.Add(textAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddTextAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Adds polyline annotation in Images document
        /// </summary>
        public static void AddPolylineAnnotation()
        {
            try
            {
                //ExStart:AddPolylineAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Polyline annotation
                AnnotationInfo polylineAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 35.0),
                    Box         = new Rectangle(250f, 35f, 102f, 12f),
                    PageNumber  = 0,
                    PenColor    = 1201033,
                    PenWidth    = 2,
                    SvgPath     = "M250.8280751173709,48.209295774647885l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l1.3973708920187793,-0.6986854460093896l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l2.096056338028169,-1.3973708920187793l3.493427230046948,-1.3973708920187793l0.6986854460093896,-0.6986854460093896l1.3973708920187793,-1.3973708920187793l0.6986854460093896,0l1.3973708920187793,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l0,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0,-0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.096056338028169,-0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l1.3973708920187793,0l2.096056338028169,0l5.589483568075117,0l1.3973708920187793,0l2.096056338028169,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l2.096056338028169,1.3973708920187793l0.6986854460093896,0l0.6986854460093896,0l0,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0.6986854460093896l0,0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0.6986854460093896l1.3973708920187793,0.6986854460093896l3.493427230046948,0.6986854460093896l1.3973708920187793,0.6986854460093896l2.096056338028169,0.6986854460093896l1.3973708920187793,0.6986854460093896l1.3973708920187793,0l1.3973708920187793,0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.7947417840375586,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0",
                    Type        = AnnotationType.Polyline,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(polylineAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddPolylineAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Adds text strikeout annotation in Images document
        /// </summary>
        public static void AddTextStrikeOutAnnotation()
        {
            try
            {
                //ExStart:AddTextStrikeOutAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Text strikeout annotation
                AnnotationInfo strikeoutAnnotation = new AnnotationInfo
                {
                    Box         = new Rectangle((float)101.76, (float)688.73, (float)321.85, 27),
                    PageNumber  = 1,
                    SvgPath     = "[{\"x\":101.76,\"y\":400.05},{\"x\":255.9,\"y\":400.05},{\"x\":101.76,\"y\":378.42},{\"x\":255.91,\"y\":378.42},{\"x\":101.76,\"y\":374.13},{\"x\":423.61,\"y\":374.13},{\"x\":101.76,\"y\":352.5},{\"x\":423.61,\"y\":352.5}]",
                    Type        = AnnotationType.TextStrikeout,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(strikeoutAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddTextStrikeOutAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Adds point annotation in Images document
        /// </summary>
        public static void AddPointAnnotation()
        {
            try
            {
                //ExStart:AddPointAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);
                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Point annotation
                AnnotationInfo pointAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 81.0),
                    Box         = new Rectangle(212f, 81f, 142f, 0.0f),
                    PageNumber  = 0,
                    Type        = AnnotationType.Point,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(pointAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddPointAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 25
0
        public override AnnotationInfo AnnotateSlides()
        {
            // init possible types of annotations
            AnnotationInfo textFieldAnnotation = InitAnnotationInfo();

            return(textFieldAnnotation);
        }
Ejemplo n.º 26
0
        public void XElementAnnotationTestDifferentAnnotationNamespaceModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                             new XElement("{http://foo1}Child",
                                          new XElement("{http://foo2}GrandChild",
                                                       "1"
                                                       )
                                          )
                             );

            AnnotationInfo annotationInfo = new AnnotationInfo()
            {
                Namespace = "http://foo", Name = "Annotation"
            };

            List <ElementInfo> annotationPath = new List <ElementInfo>()
            {
                new ElementInfo()
                {
                    Name = "Container", Type = AnnotatableElementType.EntityContainer
                },
                new ElementInfo()
                {
                    Name = "SimpleSet", Type = AnnotatableElementType.EntitySet
                }
            };
            ElementLocation annotationLocation = new ElementLocation()
            {
                Namespace = "DefaultNamespace", ElementPath = annotationPath
            };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.DifferentAnnotationNamespaceCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.DifferentAnnotationNamespaceModel());
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Adds text replacement annotation in Images document
        /// </summary>
        public static void AddTextReplacementAnnotation()
        {
            try
            {
                //ExStart:AddTextReplacementAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Text replacement annotation
                AnnotationInfo textReplacementAnnotation = new AnnotationInfo
                {
                    Box         = new Rectangle((float)101.76, (float)826.73, (float)229, 27),
                    PageNumber  = 1,
                    SvgPath     = "[{\"x\":101.76,\"y\":264.69},{\"x\":331,\"y\":264.69},{\"x\":101.76,\"y\":243.06},{\"x\":331,\"y\":243}]",
                    Type        = AnnotationType.TextReplacement,
                    CreatorName = "Anonym A.",
                    FieldText   = "Replaced text",
                    FontSize    = 10
                };
                // Add annotation to list
                annotations.Add(textReplacementAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddTextReplacementAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 28
0
        public void XElementAnnotationTestAnnotationWithEntitySetTagInEntityContainerModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}EntitySet",
                             "1"
                             );

            AnnotationInfo annotationInfo = new AnnotationInfo()
            {
                Namespace = "http://foo", Name = "EntitySet"
            };

            List <ElementInfo> annotationPath = new List <ElementInfo>()
            {
                new ElementInfo()
                {
                    Name = "Container", Type = AnnotatableElementType.EntityContainer
                }
            };
            ElementLocation annotationLocation = new ElementLocation()
            {
                Namespace = "DefaultNamespace", ElementPath = annotationPath
            };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithEntitySetTagInEntityContainerCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.AnnotationWithEntitySetTagInEntityContainerModel());
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Adds text redaction annotation in Images document
        /// </summary>
        public static void AddTextRedactionAnnotation()
        {
            try
            {
                //ExStart:AddTextRedactionAnnotation
                // Get input file stream
                Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite);

                // Initialize list of AnnotationInfo
                List <AnnotationInfo> annotations = new List <AnnotationInfo>();

                // Text redaction annotation
                AnnotationInfo textRedactionAnnotation = new AnnotationInfo
                {
                    Box         = new Rectangle((float)448.56, (float)212.4, 210, 27),
                    PageNumber  = 0,
                    SvgPath     = "[{\"x\":448.56,\"y\":326.5},{\"x\":658.7,\"y\":326.5},{\"x\":448.56,\"y\":302.43},{\"x\":658.7,\"y\":302.43}]",
                    Type        = AnnotationType.TextRedaction,
                    CreatorName = "Anonym A."
                };
                // Add annotation to list
                annotations.Add(textRedactionAnnotation);

                // Export annotation and save output file
                CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Images);
                //ExEnd:AddTextRedactionAnnotation
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 30
0
        public void XElementAnnotationTestAnnotationWithValueCsdl()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                             "Value 1.0"
                             );

            AnnotationInfo annotationInfo = new AnnotationInfo()
            {
                Namespace = "http://foo", Name = "Annotation"
            };

            List <ElementInfo> annotationPath = new List <ElementInfo>()
            {
                new ElementInfo()
                {
                    Name = "SimpleFunction", Type = AnnotatableElementType.Function
                },
                new ElementInfo()
                {
                    Name = "Id", Type = AnnotatableElementType.Parameter
                }
            };
            ElementLocation annotationLocation = new ElementLocation()
            {
                Namespace = "DefaultNamespace", ElementPath = annotationPath
            };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithValueCsdl(), expectedAnnotation, annotationInfo, annotationLocation);
        }
Ejemplo n.º 31
0
 public StadModel(string type, AnnotationInfo annotationInfo, ReadOnlyCollection <MemberDefinition> members)
 {
     Type           = type;
     TypeCode       = Utility.ToTypeCode(type);
     AnnotationInfo = annotationInfo;
     Members        = members;
 }
Ejemplo n.º 32
0
        public void XElementAnnotationTestAnnotationWithoutChildrenModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation");

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "ComplexType", Type = AnnotatableElementType.ComplexType }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithoutChildrenCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.AnnotationWithoutChildrenModel());
        }
Ejemplo n.º 33
0
        public void AnnotateProcEnsures(Procedure proc, Implementation impl, ProverContext ctxt)
        {
            Contract.Requires(impl != null);

            CurrentLocalVariables = impl.LocVars;

            // collect the variables needed in the invariant
            List<Expr> exprs = new List<Expr>();
            List<Variable> vars = new List<Variable>();
            List<string> names = new List<string>();

                foreach (Variable v in program.GlobalVariables())
                {
                    vars.Add(v);
                    exprs.Add(new OldExpr(Token.NoToken,new IdentifierExpr(Token.NoToken, v)));
                    names.Add(v.Name);
                }
                foreach (IdentifierExpr ie in proc.Modifies)
                        {
                            if (ie.Decl == null)
                                continue;
                            vars.Add(ie.Decl);
                            exprs.Add(ie);
                            names.Add(ie.Decl.Name + "_out");
                        }
                foreach (Variable v in proc.InParams)
                {
                            Contract.Assert(v != null);
                            vars.Add(v);
                            exprs.Add(new OldExpr(Token.NoToken, new IdentifierExpr(Token.NoToken, v)));
                            names.Add(v.Name);
                }
                foreach (Variable v in proc.OutParams)
                {
                            Contract.Assert(v != null);
                            vars.Add(v);
                            exprs.Add(new IdentifierExpr(Token.NoToken, v));
                            names.Add(v.Name);
                }
                string name = impl.Name + "_summary";
                summaries.Add(name, true);
                TypedIdent ti = new TypedIdent(Token.NoToken, "", Microsoft.Boogie.Type.Bool);
                Contract.Assert(ti != null);
                Formal returnVar = new Formal(Token.NoToken, ti, false);
                Contract.Assert(returnVar != null);
                var function = new Function(Token.NoToken, name, vars, returnVar);
                ctxt.DeclareFunction(function, "");

                Expr invarExpr = new NAryExpr(Token.NoToken, new FunctionCall(function), exprs);

            proc.Ensures.Add(new Ensures(Token.NoToken, false, invarExpr, "", null));

            var info = new AnnotationInfo();
            info.filename = proc.tok.filename;
            info.lineno = proc.Line;
            info.argnames = names.ToArray();
            info.type = AnnotationInfo.AnnotationType.ProcedureSummary;
            annotationInfo.Add(name, info);
        }
Ejemplo n.º 34
0
        public void XElementAnnotationTestAnnotationWithEntitySetTagInEntityContainerModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}EntitySet",
                    "1"
                );

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "EntitySet" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "Container", Type = AnnotatableElementType.EntityContainer }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithEntitySetTagInEntityContainerCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.AnnotationWithEntitySetTagInEntityContainerModel());
        }
Ejemplo n.º 35
0
		private void Convert5()
		{
			// What we have at this point is annotations for wordforms, punctuation forms, and
			// segments, but the offsets are useless. Even if LL could produce some offsets, they
			// would be based on 8-bit data which may have been changed when converted to Unicode.
			// Fortunately, the annotations can be ordered by id since they are created in the
			// order in which they occurred in LL (e.g., word/punctuation annotations followed by
			// the closing segment annotation. There may be mismatches in areas between LL and FW.
			// LL segments may have any punctuation mid-segment. LL can also have wordforms with
			// digits. FW can not have either of these (at this point).

			SqlConnection dbConnection = null;
			SqlCommand sqlCommand = null;
			SqlDataReader reader = null;
			string sConnection = string.Format("Server={0}; Database={1}; User ID=FWDeveloper; " +
				"Password=careful; Pooling=false;", m_cache.ServerName, m_cache.DatabaseName);

			dbConnection = new SqlConnection(sConnection);
			dbConnection.Open();
			try
			{

				// We need to process all of the word/punctuation annotations by
				// locating them in the corresponding baseline text and setting all of their begin/end
				// offsets.
				// This gives us the wordform and punctuation annotations in text order, along with the
				// paragraph id and the wordform text. The order by here only works directly after import
				// from LinguaLinks. With this information we need to set the offsets for each annotation.
				// Note 20 is a wordform, but is considered as punctuation by Flex. What will happen here?
				// Return values:
				//   Id of CmBaseAnnotation
				//   Guid of annotation type
				//   Id of paragraph holding wordform
				//   BeginOffset of wordform in paragraph (not really, so this isn't used)
				//   EndOffset of wordform in paragraph (actually length of word from LL. This is only
				//       used for punctuation forms.
				//   Text of wordform (null for puncutation and segment markers)
				// We are assuming that we can ignore the writing system when finding wordforms in text.
				List<AnnotationInfo> annotations = null;
				annotations = new List<AnnotationInfo>();
				string sqlCmd =
				"select cba.id, cad.guid$, cba.BeginObject, cba.BeginOffset, cba.EndOffset, wf.Id" +
				" from CmBaseAnnotation_ cba" +
				" join CmAnnotationDefn_ cad on cad.Id = cba.AnnotationType" +
				" left outer join CmObject co1 on co1.Id = cba.InstanceOf" +
				" left outer join CmObject co2 on co2.Id = co1.Owner$" +
				" left outer join CmObject co3 on co3.Id = co2.Owner$" +
				" left outer join WfiWordform wf on wf.Id in (co1.Id, co2.Id, co3.Id)" +
				" where cba.CompDetails like 'LLImport'" +
				" order by cba.id";
				sqlCommand = dbConnection.CreateCommand();
				sqlCommand.CommandText = sqlCmd;
				reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.Default);
				while (reader.Read())
				{
					AnnotationInfo annotation = new AnnotationInfo();
					annotation.annotationId = reader.GetInt32(0);
					annotation.annotationType = reader.GetGuid(1);
					if (reader.IsDBNull(2))
						annotation.paragraphId = 0;
					else
						annotation.paragraphId = reader.GetInt32(2);
					annotation.beginOffset = reader.GetInt32(3);
					annotation.endOffset = reader.GetInt32(4);
					if (reader.IsDBNull(5))
						annotation.wfId = 0;
					else
						annotation.wfId = reader.GetInt32(5);
					// For some reason we are getting a null paragraph for incomplete texts.
					if (annotation.paragraphId > 0)
						annotations.Add(annotation);
				}
				reader.Close();

				// Load the alternative forms for each WfiWordform.  This is needed to handle
				// texts from multiple writing systems.  See LT-7290.
				// We don't currently use the ws value, but load it anyway.
				Dictionary<int, Dictionary<int, string>> wordforms = new Dictionary<int, Dictionary<int, string>>();
				int obj;
				int ws;
				string txt;
				Dictionary<int, string> wfalts;
				sqlCmd = "SELECT Obj, Ws, Txt FROM WfiWordform_Form";
				sqlCommand = dbConnection.CreateCommand();
				sqlCommand.CommandText = sqlCmd;
				reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.Default);
				while (reader.Read())
				{
					obj = reader.GetInt32(0);
					ws = reader.GetInt32(1);
					if (reader.IsDBNull(2))
						txt = "";
					else
						txt = reader.GetString(2);
					if (wordforms.TryGetValue(obj, out wfalts))
					{
						wfalts.Add(ws, txt);
					}
					else
					{
						wfalts = new Dictionary<int, string>();
						wfalts.Add(ws, txt);
						wordforms.Add(obj, wfalts);
					}
				}
				reader.Close();

				// This retrieves the interlinear text paragraphs
				//   Id of paragraph
				//   Text of paragraph (ignoring formatting and ws)
				Dictionary<int, string> paragraphs = new Dictionary<int, string>();
				sqlCmd = "select stp.Id, stp.Contents from Text_Contents tc" +
					" join StText_Paragraphs stps on stps.src = tc.dst" +
					" join StTxtPara_ stp on stp.id = stps.dst";
				sqlCommand = dbConnection.CreateCommand();
				sqlCommand.CommandText = sqlCmd;
				reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.Default);
				int paragraphId;
				string paraContents = null;
				while (reader.Read())
				{
					paragraphId = reader.GetInt32(0);
					if (reader.IsDBNull(1))
						paraContents = "";
					else
						paraContents = reader.GetString(1).ToLower();
					paragraphs.Add(paragraphId, paraContents);
				}
				reader.Close();

				// Go through all of the WordformsInContext and set their offsets
				// based on the baseline string.
				int offsetInString = 0;
				int currentContentId = 0;
				string contents = null;
				int cUnfound = 0;
				for (int iann = 0; iann < annotations.Count; ++iann)
				{
					AnnotationInfo ann = annotations[iann];
					if (ann.annotationType.ToString() != LangProject.kguidAnnWordformInContext)
						continue;
					if (ann.paragraphId != currentContentId)
					{
						currentContentId = ann.paragraphId;
						paragraphs.TryGetValue(currentContentId, out contents);
						offsetInString = 0;
					}
					Debug.Assert(contents != null);
					if (ann.wfId == 0)
						continue;
					if (!wordforms.TryGetValue(ann.wfId, out wfalts))
						continue;
					Dictionary<int, string>.Enumerator wfit = wfalts.GetEnumerator();
					bool fFound = false;
					while (wfit.MoveNext())
					{
						string form = wfit.Current.Value;
						int offsetBegin = contents.IndexOf(form, offsetInString);
						if (offsetBegin != -1)
						{
							// REVIEW:  SHOULD WE DOUBLECHECK ws?
							ann.beginOffset = offsetBegin;
							ann.endOffset = ann.beginOffset + form.Length;
							fFound = true;
							break;
						}
					}
					if (!fFound)
					{
						// We can't find the wordform for some reason.
						ann.beginOffset = offsetInString;
						ann.endOffset = ann.beginOffset;
						++cUnfound;
					}
					offsetInString = ann.endOffset;
					annotations[iann] = ann;
				}

				// Now that the wordform offsets are set, we need to set the offsets for punctuation forms
				// and segments. We can use the begin offset of the first word/punct and the
				// last end offset to set the following segment begin/end offsets.
				int beginSegmentOffset = 0;
				int endSegmentOffset = 0;
				for (int iann = 0; iann < annotations.Count; ++iann)
				{
					AnnotationInfo ann = annotations[iann];
					if (ann.paragraphId != currentContentId)
					{
						currentContentId = ann.paragraphId;
						beginSegmentOffset = 0;
						endSegmentOffset = 0;
					}
					switch (ann.annotationType.ToString())
					{
						case LangProject.kguidAnnWordformInContext:
							endSegmentOffset = ann.endOffset;
							break;
						case LangProject.kguidAnnPunctuationInContext:
							ann.beginOffset = endSegmentOffset;
							// Note, endOffset in LL is actually the length of the punctuation
							// text. We'll assume here that the length didn't change when
							// converted to Unicode.
							endSegmentOffset = ann.beginOffset + ann.endOffset;
							ann.endOffset = endSegmentOffset;
							annotations[iann] = ann;
							break;
						case LangProject.kguidAnnTextSegment:
							ann.beginOffset = beginSegmentOffset;
							ann.endOffset = endSegmentOffset;
							annotations[iann] = ann;
							beginSegmentOffset = endSegmentOffset;
							break;
						default:
							break; // This shouldn't happen.
					}
				}

				// Now write all of the offsets to the database.
				sqlCommand = dbConnection.CreateCommand();
				foreach (AnnotationInfo ann in annotations)
				{
					sqlCmd = String.Format("update CmBaseAnnotation set BeginOffset = {0}, EndOffset = {1} where Id = {2}",
						ann.beginOffset.ToString(), ann.endOffset.ToString(), ann.annotationId.ToString());
					sqlCommand.CommandText = sqlCmd;
					sqlCommand.ExecuteNonQuery();
				}
			}
			finally
			{
				dbConnection.Close();
			}

			if (m_cache.DatabaseAccessor.IsTransactionOpen())
				m_cache.DatabaseAccessor.CommitTrans();

			// Move the CmAgentEvaluations to the original CmAgent and delete the one from LL.
			// Also remove the LinguaLinks flags from CmAgent_Details and CmAnotation_CompDetails.
			m_cache.DatabaseAccessor.BeginTrans();
			DbOps.ExecuteStoredProc(
				m_cache,
				"declare @origOwner int, @LLOwner int, @sId nvarchar(20) " +
				"select top 1 @LLOwner = Owner$ from CmAgentEvaluation_ where Details = 'Imported from Lingualinks' " +
				"select top 1 @origOwner = id from CmAgent where Human = 1 and id != @LLOwner " +
				"update CmAgentEvaluation_ set Owner$ = @origOwner where Details = 'Imported from Lingualinks' " +
				"update CmAgentEvaluation set Details = NULL where Details = 'Imported from Lingualinks' " +
				"set @sId = convert(nvarchar(20), @LLOwner) " +
				"exec DeleteObjects @sId " +
				"UPDATE CmAnnotation SET CompDetails=NULL WHERE CompDetails LIKE 'LLImport'",
				null);
			m_cache.DatabaseAccessor.CommitTrans();
		}
Ejemplo n.º 36
0
        public void XElementAnnotationTestComplexNamespaceOverlappingModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                    new XElement("{http://foo}Child",
                        new XElement("{http://foo1}GrandChild",
                            new XElement("{http://foo}GreatGrandChild",
                              "1"
                            )
                        )
                    ),
                    new XElement("{http://foo1}Child",
                        new XElement("{http://foo}GrandChild",
                          "1"
                        )
                    )
                );

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "Container", Type = AnnotatableElementType.EntityContainer },
                new ElementInfo() { Name = "SimpleFunction", Type = AnnotatableElementType.FunctionImport }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "Default", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.ComplexNamespaceOverlappingCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.ComplexNamespaceOverlappingModel());
        }
Ejemplo n.º 37
0
        public void XElementAnnotationTestDifferentAnnotationNamespaceModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                    new XElement("{http://foo1}Child",
                        new XElement("{http://foo2}GrandChild",
                            "1"
                        )
                    )
                );

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "Container", Type = AnnotatableElementType.EntityContainer },
                new ElementInfo() { Name = "SimpleSet", Type = AnnotatableElementType.EntitySet }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.DifferentAnnotationNamespaceCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.DifferentAnnotationNamespaceModel());
        }
Ejemplo n.º 38
0
        public void XElementAnnotationTestFunctionImportParameterWithAnnotationModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation", 1);

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "SimpleFunction", Type = AnnotatableElementType.Function },
                new ElementInfo() { Name = "Name", Type = AnnotatableElementType.Parameter },
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "Default", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.ActionImportParameterWithAnnotationCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.OperationImportParameterWithAnnotationModel());
        }
Ejemplo n.º 39
0
        private void AnnotateBlock(Implementation impl, ProverContext ctxt, Block header)
        {
            Contract.Assert(header != null);

            string name = impl.Name + "_" + header.Label + "_invar";
            if (annotationInfo.ContainsKey(name))
                return;

            // collect the variables needed in the invariant
            List<Expr> exprs = new List<Expr>();
            List<Variable> vars = new List<Variable>();
            List<string> names = new List<string>();

            if (style == AnnotationStyle.Flat)
            {
                // in flat mode, all live globals should be in live set
            #if false
                foreach (Variable v in program.GlobalVariables())
                {
                    vars.Add(v);
                    names.Add(v.ToString());
                    exprs.Add(new IdentifierExpr(Token.NoToken, v));
                }
            #endif
                foreach (Variable v in /* impl.LocVars */ header.liveVarsBefore)
                {
                    if (!(v is BoundVariable))
                    {
                        vars.Add(v);
                        names.Add(v.ToString());
                        exprs.Add(new IdentifierExpr(Token.NoToken, v));
                    }
                }
            }
            else
            {
                foreach (Variable v in program.GlobalVariables())
                {
                    vars.Add(v);
                    names.Add("@old_" + v.ToString());
                    exprs.Add(new OldExpr(Token.NoToken, new IdentifierExpr(Token.NoToken, v)));
                }
                foreach (IdentifierExpr ie in impl.Proc.Modifies)
                {
                    if (ie.Decl == null)
                        continue;
                    vars.Add(ie.Decl);
                    names.Add(ie.Decl.ToString());
                    exprs.Add(ie);
                }
                foreach (Variable v in impl.Proc.InParams)
                {
                    Contract.Assert(v != null);
                    vars.Add(v);
                    names.Add("@old_" + v.ToString());
                    exprs.Add(new OldExpr(Token.NoToken, new IdentifierExpr(Token.NoToken, v)));
                }
                foreach (Variable v in impl.LocVars)
                {
                    vars.Add(v);
                    names.Add(v.ToString());
                    exprs.Add(new IdentifierExpr(Token.NoToken, v));
                }
            }

            TypedIdent ti = new TypedIdent(Token.NoToken, "", Microsoft.Boogie.Type.Bool);
            Contract.Assert(ti != null);
            Formal returnVar = new Formal(Token.NoToken, ti, false);
            Contract.Assert(returnVar != null);
            var function = new Function(Token.NoToken, name, vars, returnVar);
            ctxt.DeclareFunction(function, "");

            Expr invarExpr = new NAryExpr(Token.NoToken, new FunctionCall(function), exprs);
            var invarAssertion = new AssertCmd(Token.NoToken, invarExpr);
            List<Cmd> newCmds = new List<Cmd>();
            newCmds.Add(invarAssertion);

            // make a record in annotationInfo;
            var info = new AnnotationInfo();
            info.filename = header.tok.filename;
            info.lineno = header.Line;
            info.argnames = names.ToArray();
            info.type = AnnotationInfo.AnnotationType.LoopInvariant;
            annotationInfo.Add(name, info);
            // get file and line info from havoc, if there is...
            if (header.Cmds.Count > 0)
            {
                PredicateCmd bif = header.Cmds[0] as PredicateCmd;
                if (bif != null)
                {
                    string foo = QKeyValue.FindStringAttribute(bif.Attributes, "sourcefile");
                    if (foo != null)
                        info.filename = foo;
                    int bar = QKeyValue.FindIntAttribute(bif.Attributes, "sourceline", -1);
                    if (bar != -1)
                        info.lineno = bar;
                }
            }
            var thing = header;
            foreach (Cmd c in header.Cmds)
            {
                newCmds.Add(c);
            }
            header.Cmds = newCmds;
        }
Ejemplo n.º 40
0
        public void XElementAnnotationTestNestedXElementWithNoValueCsdl()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                    new XElement("{http://foo}Child",
                        new XElement("{http://foo}GrandChild",
                            new XElement("{http://foo}GreatGrandChild",
                                new XElement("{http://foo}GreateGreatGrandChild")
                            )
                        )
                    )
                );

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "SimpleType", Type = AnnotatableElementType.ComplexType },
                new ElementInfo() { Name = "Id", Type = AnnotatableElementType.Property }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.NestedXElementWithNoValueCsdl(), expectedAnnotation, annotationInfo, annotationLocation);
        }
Ejemplo n.º 41
0
        public void XElementAnnotationTestEnumWithAnnotationCsdl()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation", 1);

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "Spicy", Type = AnnotatableElementType.Enum }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.EnumWithAnnotationCsdl(), expectedAnnotation, annotationInfo, annotationLocation);
        }
Ejemplo n.º 42
0
        private string GetElementAnnotationValue(IEdmModel model, AnnotationInfo annotationInfo, ElementLocation annotationLocation)
        {
            IEdmElement element = GetElementByElementLocation(model, annotationLocation);

            if (null != element)
            {
                var annotation = model.GetAnnotationValue(element, annotationInfo.Namespace, annotationInfo.Name);

                if (null != annotation)
                {
                    return null != (annotation as EdmStringConstant) ? (annotation as EdmStringConstant).Value : string.Empty;
                }
            }

            return string.Empty;
        }
Ejemplo n.º 43
0
 private bool ValidateAnnotation(IEdmModel model, XElement expectedAnnotation, AnnotationInfo annotationInfo, ElementLocation annotationLocation)
 {
     string annotationValue = this.GetElementAnnotationValue(model, annotationInfo, annotationLocation);
     
     if (string.IsNullOrEmpty(annotationValue))
     {
         return false;
     }
     
     var actualAnnotation = XElement.Parse(annotationValue);
     
     return expectedAnnotation.ToString().Equals(actualAnnotation.ToString());
 }
Ejemplo n.º 44
0
        private void AnnotationRoundTripCsdlCheck(IEnumerable<XElement> csdls, XElement expectedAnnotation, AnnotationInfo annotationInfo, ElementLocation annotationLocation, IEdmModel model)
        {
            var errors = new EdmLibTestErrors();
            this.VerifySemanticValidation(model, EdmVersion.Latest, errors);

            var isValid = this.ValidateAnnotation(model, expectedAnnotation, annotationInfo, annotationLocation);
            Assert.IsTrue(isValid, "Invalid XElement annotation.");
            IEnumerable<EdmError> serializationErrors;

            var serializedModelCsdls = this.GetSerializerResult(model, EdmVersion.Latest, out serializationErrors).Select(n => XElement.Parse(n));
            Assert.AreEqual(0, serializationErrors.Count(), "Round trip test should not have serialization errors: " + Environment.NewLine + String.Join(Environment.NewLine, serializationErrors));

            var csdlsWithLastestEdmVersion = ModelBuilderHelpers.ReplaceCsdlNamespacesForEdmVersion(csdls.ToArray(), EdmVersion.Latest).ToList();
            new ConstructiveApiCsdlXElementComparer().Compare(csdlsWithLastestEdmVersion, serializedModelCsdls.ToList());
        }
Ejemplo n.º 45
0
        private void AnnotationRoundTripCsdlCheck(IEnumerable<XElement> csdls, XElement expectedAnnotation, AnnotationInfo annotationInfo, ElementLocation annotationLocation)
        {
            var model = this.GetParserResult(csdls);

            this.AnnotationRoundTripCsdlCheck(csdls, expectedAnnotation, annotationInfo, annotationLocation, model);
        }
Ejemplo n.º 46
0
        public void XElementAnnotationTestNavigationPropertyWithAnnotationModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation", 1);

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "Person", Type = AnnotatableElementType.EntityType },
                new ElementInfo() { Name = "Friends", Type = AnnotatableElementType.NavigationProperty }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.NavigationPropertyWithAnnotationCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.NavigationPropertyWithAnnotationModel());
        }
Ejemplo n.º 47
0
using System;
Ejemplo n.º 48
0
        public void XElementAnnotationTestAnnotationWithValueCsdl()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                    "Value 1.0"
                );

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "SimpleFunction", Type = AnnotatableElementType.Function },
                new ElementInfo() { Name = "Id", Type = AnnotatableElementType.Parameter }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithValueCsdl(), expectedAnnotation, annotationInfo, annotationLocation);
        }
Ejemplo n.º 49
0
        public void XElementAnnotationTestAnnotationWithSchemaTagValueModel()
        {
            XElement expectedAnnotation =
                new XElement("{http://foo}Annotation",
                    "</Schema>"
                );

            AnnotationInfo annotationInfo = new AnnotationInfo() { Namespace = "http://foo", Name = "Annotation" };

            List<ElementInfo> annotationPath = new List<ElementInfo>()
            {
                new ElementInfo() { Name = "SimpleType", Type = AnnotatableElementType.EntityType }
            };
            ElementLocation annotationLocation = new ElementLocation() { Namespace = "DefaultNamespace", ElementPath = annotationPath };

            this.AnnotationRoundTripCsdlCheck(XElementAnnotationModelBuilder.AnnotationWithSchemaTagValueCsdl(), expectedAnnotation, annotationInfo, annotationLocation, XElementAnnotationModelBuilder.AnnotationWithSchemaTagValueModel());
        }
Ejemplo n.º 50
0
 public void AddAnnotationInfo(AnnotationInfo info, bool isReadOnly)
 {
     var newAnnot = Create(new Rect(info.TopLeft.X, info.TopLeft.Y, info.Width, info.Height), info.Comment, isReadOnly, info.RadiusX, info.RadiuxY);
     SetAnnotationDeselected(newAnnot);
     _Annotations.Add(newAnnot);
 }