public void AddFootnote()
        {
            //ExStart
            //ExFor:Footnote
            //ExFor:InlineStory
            //ExFor:InlineStory.Paragraphs
            //ExFor:InlineStory.FirstParagraph
            //ExFor:FootnoteType
            //ExFor:Footnote.#ctor
            //ExSummary:Shows how to add a footnote to a paragraph in the document.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.Write("Some text is added.");

            Footnote footnote = new Footnote(doc, FootnoteType.Footnote);
            builder.CurrentParagraph.AppendChild(footnote);
            footnote.Paragraphs.Add(new Paragraph(doc));
            footnote.FirstParagraph.Runs.Add(new Run(doc, "Footnote text."));
            //ExEnd

            Assert.AreEqual("Footnote text.", doc.GetChildNodes(NodeType.Footnote, true)[0].ToTxt().Trim());
        }
        public async Task CopyFootnotes()
        {
            var release   = new Release();
            var amendment = new Release();

            var subject = new Subject();

            var filter = new Filter
            {
                Label = "Test filter 1"
            };

            var filterGroup = new FilterGroup
            {
                Filter = filter,
                Label  = "Test filter group 1"
            };

            var filterItem = new FilterItem
            {
                Label       = "Test filter item 1",
                FilterGroup = filterGroup
            };

            var indicator = new Indicator
            {
                Label          = "Test indicator 1",
                IndicatorGroup = new IndicatorGroup()
            };

            var footnote1 = new Footnote
            {
                Content  = "Test footnote 1",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = subject
                    }
                },
                Filters = new List <FilterFootnote>
                {
                    new FilterFootnote
                    {
                        Filter = filter
                    }
                },
                FilterGroups = new List <FilterGroupFootnote>
                {
                    new FilterGroupFootnote
                    {
                        FilterGroup = filterGroup
                    }
                },
                FilterItems = new List <FilterItemFootnote>
                {
                    new FilterItemFootnote
                    {
                        FilterItem = filterItem
                    }
                },
                Indicators = new List <IndicatorFootnote>
                {
                    new IndicatorFootnote
                    {
                        Indicator = indicator
                    }
                }
            };

            var footnote2 = new Footnote
            {
                Content  = "Test footnote 2",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = subject
                    }
                },
                Filters      = new List <FilterFootnote>(),
                FilterGroups = new List <FilterGroupFootnote>(),
                FilterItems  = new List <FilterItemFootnote>(),
                Indicators   = new List <IndicatorFootnote>()
            };

            var contextId = Guid.NewGuid().ToString();

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId))
                await using (var contentDbContext = InMemoryApplicationDbContext(contextId))
                {
                    await statisticsDbContext.AddRangeAsync(release, amendment);

                    await statisticsDbContext.AddRangeAsync(footnote1, footnote2);

                    await statisticsDbContext.SaveChangesAsync();

                    await contentDbContext.AddRangeAsync(new Content.Model.Release
                    {
                        Id = release.Id
                    },
                                                         new Content.Model.Release
                    {
                        Id = amendment.Id
                    });

                    await contentDbContext.SaveChangesAsync();
                }

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId))
                await using (var contentDbContext = InMemoryApplicationDbContext(contextId))
                {
                    var footnoteRepository = new Mock <IFootnoteRepository>(Strict);

                    footnoteRepository
                    .Setup(s => s.GetFootnotes(release.Id))
                    .Returns(new List <Footnote>
                    {
                        footnote1,
                        footnote2
                    });

                    var newFootnote1 = new Footnote
                    {
                        Id       = Guid.NewGuid(),
                        Releases = new List <ReleaseFootnote>
                        {
                            new ReleaseFootnote
                            {
                                ReleaseId = amendment.Id
                            }
                        }
                    };

                    var newFootnote2 = new Footnote
                    {
                        Id       = Guid.NewGuid(),
                        Releases = new List <ReleaseFootnote>
                        {
                            new ReleaseFootnote
                            {
                                ReleaseId = amendment.Id
                            }
                        }
                    };

                    footnoteRepository
                    .Setup(s => s.GetFootnote(newFootnote1.Id))
                    .ReturnsAsync(newFootnote1);

                    footnoteRepository
                    .Setup(s => s.GetFootnote(newFootnote2.Id))
                    .ReturnsAsync(newFootnote2);

                    var guidGenerator = new Mock <IGuidGenerator>();

                    guidGenerator
                    .SetupSequence(s => s.NewGuid())
                    .Returns(newFootnote1.Id)
                    .Returns(newFootnote2.Id);

                    var service = SetupFootnoteService(
                        statisticsDbContext,
                        contentDbContext,
                        footnoteRepository: footnoteRepository.Object,
                        guidGenerator: guidGenerator.Object);

                    var result =
                        await service.CopyFootnotes(release.Id, amendment.Id);

                    Assert.True(result.IsRight);
                    Assert.Equal(2, result.Right.Count);
                    Assert.Contains(newFootnote1, result.Right);
                    Assert.Contains(newFootnote2, result.Right);

                    MockUtils.VerifyAllMocks(footnoteRepository);
                }

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId))
            {
                var newFootnotesFromDb = statisticsDbContext
                                         .Footnote
                                         .Include(f => f.Filters)
                                         .Include(f => f.FilterGroups)
                                         .Include(f => f.FilterItems)
                                         .Include(f => f.Releases)
                                         .Include(f => f.Subjects)
                                         .Include(f => f.Indicators)
                                         .Where(f => f.Releases.
                                                FirstOrDefault(r => r.ReleaseId == amendment.Id) != null)
                                         .OrderBy(f => f.Content)
                                         .ToList();

                Assert.Equal(2, newFootnotesFromDb.Count);
                AssertFootnoteDetailsCopiedCorrectly(footnote1, newFootnotesFromDb[0]);
                AssertFootnoteDetailsCopiedCorrectly(footnote2, newFootnotesFromDb[1]);
            }

            void AssertFootnoteDetailsCopiedCorrectly(Footnote originalFootnote, Footnote newFootnote)
            {
                Assert.Equal(newFootnote.Content, originalFootnote.Content);

                Assert.Equal(
                    originalFootnote
                    .Filters
                    .SelectNullSafe(f => f.FilterId)
                    .ToList(),
                    newFootnote
                    .Filters
                    .SelectNullSafe(f => f.FilterId)
                    .ToList());

                Assert.Equal(
                    originalFootnote
                    .FilterGroups
                    .SelectNullSafe(f => f.FilterGroupId)
                    .ToList(),
                    newFootnote
                    .FilterGroups
                    .SelectNullSafe(f => f.FilterGroupId)
                    .ToList());

                Assert.Equal(
                    originalFootnote
                    .FilterItems
                    .SelectNullSafe(f => f.FilterItemId)
                    .ToList(),
                    newFootnote
                    .FilterItems
                    .SelectNullSafe(f => f.FilterItemId)
                    .ToList());

                Assert.Equal(
                    originalFootnote
                    .Subjects
                    .SelectNullSafe(f => f.SubjectId)
                    .ToList(),
                    newFootnote
                    .Subjects
                    .SelectNullSafe(f => f.SubjectId)
                    .ToList());

                Assert.Equal(
                    originalFootnote
                    .Indicators
                    .SelectNullSafe(f => f.IndicatorId)
                    .ToList(),
                    newFootnote
                    .Indicators
                    .SelectNullSafe(f => f.IndicatorId)
                    .ToList());
            }
        }
Ejemplo n.º 3
0
            /// <summary>
            /// Called when a Footnote is encountered in the document.
            /// </summary>
            public override VisitorAction VisitFootnoteStart(Footnote footnote)
            {
                if (isHidden(footnote))
                    footnote.Remove();

                return VisitorAction.Continue;
            }
Ejemplo n.º 4
0
        internal override void VisitFootnote(Footnote footnote)
        {
            Document document = footnote.Document;

            ParagraphFormat format = null;

            Style style = document._styles[footnote._style.Value];
            if (style != null)
                format = ParagraphFormatFromStyle(style);
            else
            {
                footnote.Style = StyleNames.Footnote;
                format = document._styles[StyleNames.Footnote]._paragraphFormat;
            }

            if (footnote._format == null)
            {
                footnote._format = format.Clone();
                footnote._format._parent = footnote;
            }
            else
                FlattenParagraphFormat(footnote._format, format);

        }
        // Generates content of footnotesPart1.
        private void GenerateFootnotesPart1Content(FootnotesPart footnotesPart1)
        {
            Footnotes footnotes1 = new Footnotes();

            Footnote footnote1 = new Footnote() { Type = FootnoteEndnoteValues.Separator, Id = -1 };

            Paragraph paragraph49 = new Paragraph() { RsidParagraphAddition = "004805C1", RsidRunAdditionDefault = "004805C1" };

            Run run52 = new Run();
            SeparatorMark separatorMark2 = new SeparatorMark();

            run52.Append(separatorMark2);

            paragraph49.Append(run52);

            footnote1.Append(paragraph49);

            Footnote footnote2 = new Footnote() { Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0 };

            Paragraph paragraph50 = new Paragraph() { RsidParagraphAddition = "004805C1", RsidRunAdditionDefault = "004805C1" };

            Run run53 = new Run();
            ContinuationSeparatorMark continuationSeparatorMark2 = new ContinuationSeparatorMark();

            run53.Append(continuationSeparatorMark2);

            paragraph50.Append(run53);

            footnote2.Append(paragraph50);

            footnotes1.Append(footnote1);
            footnotes1.Append(footnote2);

            footnotesPart1.Footnotes = footnotes1;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns true if IngredientObjectNutrients instances are equal
        /// </summary>
        /// <param name="other">Instance of IngredientObjectNutrients to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(IngredientObjectNutrients other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Per100g == other.Per100g ||
                     Per100g != null &&
                     Per100g.Equals(other.Per100g)
                 ) &&
                 (
                     MeasurementUnit == other.MeasurementUnit ||
                     MeasurementUnit != null &&
                     MeasurementUnit.Equals(other.MeasurementUnit)
                 ) &&
                 (
                     Min == other.Min ||
                     Min != null &&
                     Min.Equals(other.Min)
                 ) &&
                 (
                     Max == other.Max ||
                     Max != null &&
                     Max.Equals(other.Max)
                 ) &&
                 (
                     Median == other.Median ||
                     Median != null &&
                     Median.Equals(other.Median)
                 ) &&
                 (
                     Rank == other.Rank ||
                     Rank != null &&
                     Rank.Equals(other.Rank)
                 ) &&
                 (
                     DataPoints == other.DataPoints ||
                     DataPoints != null &&
                     DataPoints.Equals(other.DataPoints)
                 ) &&
                 (
                     Footnote == other.Footnote ||
                     Footnote != null &&
                     Footnote.Equals(other.Footnote)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ));
        }
Ejemplo n.º 7
0
        public void InsertInlineStoryNodes()
        {
            //ExStart
            //ExFor:Comment.StoryType
            //ExFor:Footnote.StoryType
            //ExFor:InlineStory.EnsureMinimum
            //ExFor:InlineStory.Font
            //ExFor:InlineStory.LastParagraph
            //ExFor:InlineStory.ParentParagraph
            //ExFor:InlineStory.StoryType
            //ExFor:InlineStory.Tables
            //ExSummary:Shows how to insert InlineStory nodes.
            Document        doc      = new Document();
            DocumentBuilder builder  = new DocumentBuilder(doc);
            Footnote        footnote = builder.InsertFootnote(FootnoteType.Footnote, null);

            // Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
            Table table = new Table(doc);

            table.EnsureMinimum();

            // We can place a table inside a footnote, which will make it appear at the referencing page's footer.
            Assert.That(footnote.Tables, Is.Empty);
            footnote.AppendChild(table);
            Assert.AreEqual(1, footnote.Tables.Count);
            Assert.AreEqual(NodeType.Table, footnote.LastChild.NodeType);

            // An InlineStory has an "EnsureMinimum()" method as well, but in this case,
            // it makes sure the last child of the node is a paragraph,
            // for us to be able to click and write text easily in Microsoft Word.
            footnote.EnsureMinimum();
            Assert.AreEqual(NodeType.Paragraph, footnote.LastChild.NodeType);

            // Edit the appearance of the anchor, which is the small superscript number
            // in the main text that points to the footnote.
            footnote.Font.Name  = "Arial";
            footnote.Font.Color = Color.Green;

            // All inline story nodes have their respective story types.
            Assert.AreEqual(StoryType.Footnotes, footnote.StoryType);

            // A comment is another type of inline story.
            Comment comment = (Comment)builder.CurrentParagraph.AppendChild(new Comment(doc, "John Doe", "J. D.", DateTime.Now));

            // The parent paragraph of an inline story node will be the one from the main document body.
            Assert.AreEqual(doc.FirstSection.Body.FirstParagraph, comment.ParentParagraph);

            // However, the last paragraph is the one from the comment text contents,
            // which will be outside the main document body in a speech bubble.
            // A comment will not have any child nodes by default,
            // so we can apply the EnsureMinimum() method to place a paragraph here as well.
            Assert.Null(comment.LastParagraph);
            comment.EnsureMinimum();
            Assert.AreEqual(NodeType.Paragraph, comment.LastChild.NodeType);

            // Once we have a paragraph, we can move the builder to do it and write our comment.
            builder.MoveTo(comment.LastParagraph);
            builder.Write("My comment.");

            Assert.AreEqual(StoryType.Comments, comment.StoryType);

            doc.Save(ArtifactsDir + "InlineStory.InsertInlineStoryNodes.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "InlineStory.InsertInlineStoryNodes.docx");

            footnote = (Footnote)doc.GetChild(NodeType.Footnote, 0, true);

            TestUtil.VerifyFootnote(FootnoteType.Footnote, true, string.Empty, string.Empty,
                                    (Footnote)doc.GetChild(NodeType.Footnote, 0, true));
            Assert.AreEqual("Arial", footnote.Font.Name);
            Assert.AreEqual(Color.Green.ToArgb(), footnote.Font.Color.ToArgb());

            comment = (Comment)doc.GetChild(NodeType.Comment, 0, true);

            Assert.AreEqual("My comment.", comment.ToString(SaveFormat.Text).Trim());
        }
        public static void SetAdvancedComparingProperties(string dataDir)
        {
            //ExStart:SetAdvancedComparingProperties
            // Create the original document.
            Document        docOriginal = new Document();
            DocumentBuilder builder     = new DocumentBuilder(docOriginal);

            // Insert paragraph text with an endnote.
            builder.Writeln("Hello world! This is the first paragraph.");
            builder.InsertFootnote(FootnoteType.Endnote, "Original endnote text.");

            // Insert a table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Original cell 1 text");
            builder.InsertCell();
            builder.Write("Original cell 2 text");
            builder.EndTable();

            // Insert a textbox.
            Shape textBox = builder.InsertShape(ShapeType.TextBox, 150, 20);

            builder.MoveTo(textBox.FirstParagraph);
            builder.Write("Original textbox contents");

            // Insert a DATE field.
            builder.MoveTo(docOriginal.FirstSection.Body.AppendParagraph(""));
            builder.InsertField(" DATE ");

            // Insert a comment.
            Comment newComment = new Comment(docOriginal, "John Doe", "J.D.", DateTime.Now);

            newComment.SetText("Original comment.");
            builder.CurrentParagraph.AppendChild(newComment);

            // Insert a header.
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
            builder.Writeln("Original header contents.");

            // Create a clone of our document, which we will edit and later compare to the original.
            Document  docEdited      = (Document)docOriginal.Clone(true);
            Paragraph firstParagraph = docEdited.FirstSection.Body.FirstParagraph;

            // Change the formatting of the first paragraph, change casing of original characters and add text.
            firstParagraph.Runs[0].Text          = "hello world! this is the first paragraph, after editing.";
            firstParagraph.ParagraphFormat.Style = docEdited.Styles[StyleIdentifier.Heading1];

            // Edit the footnote.
            Footnote footnote = (Footnote)docEdited.GetChild(NodeType.Footnote, 0, true);

            footnote.FirstParagraph.Runs[1].Text = "Edited endnote text.";

            // Edit the table.
            Table table = (Table)docEdited.GetChild(NodeType.Table, 0, true);

            table.FirstRow.Cells[1].FirstParagraph.Runs[0].Text = "Edited Cell 2 contents";

            // Edit the textbox.
            textBox = (Shape)docEdited.GetChild(NodeType.Shape, 0, true);
            textBox.FirstParagraph.Runs[0].Text = "Edited textbox contents";

            // Edit the DATE field.
            FieldDate fieldDate = (FieldDate)docEdited.Range.Fields[0];

            fieldDate.UseLunarCalendar = true;

            // Edit the comment.
            Comment comment = (Comment)docEdited.GetChild(NodeType.Comment, 0, true);

            comment.FirstParagraph.Runs[0].Text = "Edited comment.";

            // Edit the header.
            docEdited.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].FirstParagraph.Runs[0].Text = "Edited header contents.";

            // Apply different comparing options.
            CompareOptions compareOptions = new CompareOptions();

            compareOptions.IgnoreFormatting        = false;
            compareOptions.IgnoreCaseChanges       = false;
            compareOptions.IgnoreComments          = false;
            compareOptions.IgnoreTables            = false;
            compareOptions.IgnoreFields            = false;
            compareOptions.IgnoreFootnotes         = false;
            compareOptions.IgnoreTextboxes         = false;
            compareOptions.IgnoreHeadersAndFooters = false;
            compareOptions.Target = ComparisonTargetType.New;

            // compare both documents.
            docOriginal.Compare(docEdited, "John Doe", DateTime.Now, compareOptions);
            docOriginal.Save(dataDir + "Document.CompareOptions.docx");

            docOriginal = new Document(dataDir + "Document.CompareOptions.docx");

            // If you set compareOptions to ignore certain types of changes,
            // then revisions done on those types of nodes will not appear in the output document.
            // You can tell what kind of node a revision was done on by looking at the NodeType of the revision's parent nodes.
            Assert.AreNotEqual(compareOptions.IgnoreFormatting, docOriginal.Revisions.Any(rev => rev.RevisionType == RevisionType.FormatChange));
            Assert.AreNotEqual(compareOptions.IgnoreCaseChanges, docOriginal.Revisions.Any(s => s.ParentNode.GetText().Contains("hello")));
            Assert.AreNotEqual(compareOptions.IgnoreComments, docOriginal.Revisions.Any(rev => HasParentOfType(rev, NodeType.Comment)));
            Assert.AreNotEqual(compareOptions.IgnoreTables, docOriginal.Revisions.Any(rev => HasParentOfType(rev, NodeType.Table)));
            Assert.AreNotEqual(compareOptions.IgnoreFields, docOriginal.Revisions.Any(rev => HasParentOfType(rev, NodeType.FieldStart)));
            Assert.AreNotEqual(compareOptions.IgnoreFootnotes, docOriginal.Revisions.Any(rev => HasParentOfType(rev, NodeType.Footnote)));
            Assert.AreNotEqual(compareOptions.IgnoreTextboxes, docOriginal.Revisions.Any(rev => HasParentOfType(rev, NodeType.Shape)));
            Assert.AreNotEqual(compareOptions.IgnoreHeadersAndFooters, docOriginal.Revisions.Any(rev => HasParentOfType(rev, NodeType.HeaderFooter)));
            //ExEnd:SetAdvancedComparingProperties
        }
Ejemplo n.º 9
0
		public void FootnoteText()
		{
			//Create new TextDocument
			TextDocument document		= new TextDocument();
			document.New();
			//Create a new Paragph
			Paragraph para				= new Paragraph(document, "P1");
			//Create some simple Text
			SimpleText stext			= new SimpleText(para, "Some simple text. And I have a footnode");
			//Create a Footnote
			Footnote fnote				= new Footnote(para, "Footer \"     Text", "1", FootnoteType.footnode);
			//Add the text content
			para.TextContent.Add(stext);
			para.TextContent.Add(fnote);
			//Add the paragraph
			document.Content.Add(para);
			//Save
			document.SaveTo("footnote.odt");
		}
        public override VisitorAction VisitFootnoteEnd(Footnote footnote)
        {
            this.structureBuilder.AppendLine("</Footnote>");

            return(VisitorAction.Continue);
        }
Ejemplo n.º 11
0
        public static void GenerateFootnotesPart1Content(FootnotesPart footnotesPart1)
        {
            var footnotes1 = new Footnotes {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "w14 w15 w16se w16cid wp14"
                }
            };

            footnotes1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            footnotes1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex");
            footnotes1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
            footnotes1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex");
            footnotes1.AddNamespaceDeclaration("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex");
            footnotes1.AddNamespaceDeclaration("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex");
            footnotes1.AddNamespaceDeclaration("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex");
            footnotes1.AddNamespaceDeclaration("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex");
            footnotes1.AddNamespaceDeclaration("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex");
            footnotes1.AddNamespaceDeclaration("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex");
            footnotes1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            footnotes1.AddNamespaceDeclaration("aink", "http://schemas.microsoft.com/office/drawing/2016/ink");
            footnotes1.AddNamespaceDeclaration("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d");
            footnotes1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            footnotes1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            footnotes1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            footnotes1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            footnotes1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            footnotes1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            footnotes1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            footnotes1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml");
            footnotes1.AddNamespaceDeclaration("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid");
            footnotes1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex");
            footnotes1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            footnotes1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            footnotes1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            footnotes1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            var footnote1 = new Footnote {
                Type = FootnoteEndnoteValues.Separator, Id = -1
            };

            var paragraph274 = new Paragraph {
                RsidParagraphAddition = "003C529E", RsidRunAdditionDefault = "003C529E", ParagraphId = "46435F23", TextId = "77777777"
            };

            var paragraphProperties177 = new ParagraphProperties();
            var spacingBetweenLines173 = new SpacingBetweenLines {
                After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };

            paragraphProperties177.Append(spacingBetweenLines173);

            var run403         = new Run();
            var separatorMark2 = new SeparatorMark();

            run403.Append(separatorMark2);

            paragraph274.Append(paragraphProperties177);
            paragraph274.Append(run403);

            footnote1.Append(paragraph274);

            var footnote2 = new Footnote {
                Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0
            };

            var paragraph275 = new Paragraph {
                RsidParagraphAddition = "003C529E", RsidRunAdditionDefault = "003C529E", ParagraphId = "69C342F4", TextId = "77777777"
            };

            var paragraphProperties178 = new ParagraphProperties();
            var spacingBetweenLines174 = new SpacingBetweenLines {
                After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };

            paragraphProperties178.Append(spacingBetweenLines174);

            var run404 = new Run();
            var continuationSeparatorMark2 = new ContinuationSeparatorMark();

            run404.Append(continuationSeparatorMark2);

            paragraph275.Append(paragraphProperties178);
            paragraph275.Append(run404);

            footnote2.Append(paragraph275);

            footnotes1.Append(footnote1);
            footnotes1.Append(footnote2);

            footnotesPart1.Footnotes = footnotes1;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Returns true if IngredientObjectItems instances are equal
        /// </summary>
        /// <param name="other">Instance of IngredientObjectItems to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(IngredientObjectItems other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Categories == other.Categories ||
                     Categories != null &&
                     Categories.SequenceEqual(other.Categories)
                 ) &&
                 (
                     Nutrients == other.Nutrients ||
                     Nutrients != null &&
                     Nutrients.SequenceEqual(other.Nutrients)
                 ) &&
                 (
                     CalorieConversionFactor == other.CalorieConversionFactor ||
                     CalorieConversionFactor != null &&
                     CalorieConversionFactor.Equals(other.CalorieConversionFactor)
                 ) &&
                 (
                     ProteinConversionFactor == other.ProteinConversionFactor ||
                     ProteinConversionFactor != null &&
                     ProteinConversionFactor.Equals(other.ProteinConversionFactor)
                 ) &&
                 (
                     Components == other.Components ||
                     Components != null &&
                     Components.SequenceEqual(other.Components)
                 ) &&
                 (
                     Portions == other.Portions ||
                     Portions != null &&
                     Portions.SequenceEqual(other.Portions)
                 ) &&
                 (
                     CommonName == other.CommonName ||
                     CommonName != null &&
                     CommonName.Equals(other.CommonName)
                 ) &&
                 (
                     Footnote == other.Footnote ||
                     Footnote != null &&
                     Footnote.Equals(other.Footnote)
                 ) &&
                 (
                     SearchTerm == other.SearchTerm ||
                     SearchTerm != null &&
                     SearchTerm.Equals(other.SearchTerm)
                 ) &&
                 (
                     Score == other.Score ||
                     Score != null &&
                     Score.Equals(other.Score)
                 ));
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Called when a Footnote end is encountered in the document.
 /// </summary>
 public override VisitorAction VisitFootnoteEnd(Footnote footnote)
 {
     footnote.Font.Name = mFontName;
     return(VisitorAction.Continue);
 }
        public async Task GetFootnote()
        {
            var release = new Release();

            var subject = new Subject();

            var filter = new Filter
            {
                Label = "Test filter 1"
            };

            var filterGroup = new FilterGroup
            {
                Filter = filter,
                Label  = "Test filter group 1"
            };

            var filterItem = new FilterItem
            {
                Label       = "Test filter item 1",
                FilterGroup = filterGroup
            };

            var indicator = new Indicator
            {
                Label          = "Test indicator 1",
                IndicatorGroup = new IndicatorGroup()
            };

            var footnote = new Footnote
            {
                Content  = "Test footnote",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = subject
                    }
                },
                Filters = new List <FilterFootnote>
                {
                    new FilterFootnote
                    {
                        Filter = filter
                    }
                },
                FilterGroups = new List <FilterGroupFootnote>
                {
                    new FilterGroupFootnote
                    {
                        FilterGroup = filterGroup
                    }
                },
                FilterItems = new List <FilterItemFootnote>
                {
                    new FilterItemFootnote
                    {
                        FilterItem = filterItem
                    }
                },
                Indicators = new List <IndicatorFootnote>
                {
                    new IndicatorFootnote
                    {
                        Indicator = indicator
                    }
                },
            };

            var contextId = Guid.NewGuid().ToString();

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId))
                await using (var contentDbContext = InMemoryApplicationDbContext(contextId))
                {
                    await statisticsDbContext.AddAsync(release);

                    await statisticsDbContext.AddAsync(footnote);

                    await statisticsDbContext.SaveChangesAsync();

                    await contentDbContext.AddAsync(new Content.Model.Release
                    {
                        Id = release.Id
                    });

                    await contentDbContext.SaveChangesAsync();
                }

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId))
                await using (var contentDbContext = InMemoryApplicationDbContext(contextId))
                {
                    var service = SetupFootnoteService(statisticsDbContext, contentDbContext: contentDbContext);

                    var result = await service.GetFootnote(release.Id, footnote.Id);

                    Assert.True(result.IsRight);

                    Assert.Equal(footnote.Id, result.Right.Id);
                    Assert.Equal("Test footnote", result.Right.Content);

                    Assert.Single(result.Right.Releases);
                    Assert.Equal(release.Id, result.Right.Releases.First().ReleaseId);

                    Assert.Single(result.Right.Subjects);
                    Assert.Equal(subject.Id, result.Right.Subjects.First().SubjectId);

                    Assert.Single(result.Right.Filters);
                    Assert.Equal(filter.Id, result.Right.Filters.First().Filter.Id);
                    Assert.Equal(filter.Label, result.Right.Filters.First().Filter.Label);

                    Assert.Single(result.Right.FilterGroups);
                    Assert.Equal(filterGroup.Id, result.Right.FilterGroups.First().FilterGroup.Id);
                    Assert.Equal(filterGroup.Label, result.Right.FilterGroups.First().FilterGroup.Label);

                    Assert.Single(result.Right.FilterItems);
                    Assert.Equal(filterItem.Id, result.Right.FilterItems.First().FilterItem.Id);
                    Assert.Equal(filterItem.Label, result.Right.FilterItems.First().FilterItem.Label);

                    Assert.Single(result.Right.Indicators);
                    Assert.Equal(indicator.Id, result.Right.Indicators.First().Indicator.Id);
                    Assert.Equal(indicator.Label, result.Right.Indicators.First().Indicator.Label);
                }
        }
        public async Task GetFootnotes_FiltersCriteriaBySubjectId()
        {
            var release      = new Release();
            var otherRelease = new Release();

            var releaseSubject = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var otherReleaseSubject = new ReleaseSubject
            {
                Release = otherRelease,
                Subject = new Subject()
            };

            var footnote = new Footnote
            {
                Content  = "Test footnote",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                    new ReleaseFootnote
                    {
                        Release = otherRelease
                    }
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject.Subject
                    },
                    new SubjectFootnote
                    {
                        Subject = otherReleaseSubject.Subject
                    },
                },
                Filters = new List <FilterFootnote>
                {
                    new FilterFootnote
                    {
                        Filter = new Filter
                        {
                            Subject = releaseSubject.Subject
                        }
                    },
                    new FilterFootnote
                    {
                        Filter = new Filter
                        {
                            Subject = otherReleaseSubject.Subject
                        }
                    }
                },
                FilterGroups = new List <FilterGroupFootnote>
                {
                    new FilterGroupFootnote
                    {
                        FilterGroup = new FilterGroup
                        {
                            Filter = new Filter
                            {
                                Subject = releaseSubject.Subject
                            }
                        }
                    },
                    new FilterGroupFootnote
                    {
                        FilterGroup = new FilterGroup
                        {
                            Filter = new Filter
                            {
                                Subject = otherReleaseSubject.Subject
                            }
                        }
                    }
                },
                FilterItems = new List <FilterItemFootnote>
                {
                    new FilterItemFootnote
                    {
                        FilterItem = new FilterItem
                        {
                            FilterGroup = new FilterGroup
                            {
                                Filter = new Filter
                                {
                                    Subject = releaseSubject.Subject
                                }
                            }
                        }
                    },
                    new FilterItemFootnote
                    {
                        FilterItem = new FilterItem
                        {
                            FilterGroup = new FilterGroup
                            {
                                Filter = new Filter
                                {
                                    Subject = otherReleaseSubject.Subject,
                                }
                            }
                        }
                    }
                },
                Indicators = new List <IndicatorFootnote>
                {
                    new IndicatorFootnote
                    {
                        Indicator = new Indicator
                        {
                            IndicatorGroup = new IndicatorGroup
                            {
                                Subject = releaseSubject.Subject
                            }
                        }
                    },
                    new IndicatorFootnote
                    {
                        Indicator = new Indicator
                        {
                            IndicatorGroup = new IndicatorGroup
                            {
                                Subject = otherReleaseSubject.Subject
                            }
                        }
                    }
                }
            };

            var contextId = Guid.NewGuid().ToString();

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                await context.AddRangeAsync(release, otherRelease);

                await context.AddRangeAsync(releaseSubject, otherReleaseSubject);

                await context.AddAsync(footnote);

                await context.SaveChangesAsync();
            }

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                var repository = BuildFootnoteRepository(context);
                var results    = repository.GetFootnotes(release.Id, releaseSubject.SubjectId).ToList();

                Assert.Single(results);
                Assert.Equal("Test footnote", results[0].Content);

                var footnoteReleases = results[0].Releases.ToList();

                Assert.Single(footnoteReleases);
                Assert.Equal(releaseSubject.ReleaseId, footnoteReleases[0].ReleaseId);

                var footnoteSubjects = results[0].Subjects.ToList();

                Assert.Single(footnoteSubjects);
                Assert.Equal(releaseSubject.SubjectId, footnoteSubjects[0].SubjectId);

                var footnoteFilters = results[0].Filters.ToList();

                Assert.Single(footnoteSubjects);
                Assert.Equal(releaseSubject.SubjectId, footnoteFilters[0].Filter.SubjectId);

                var footnoteFilterGroups = results[0].FilterGroups.ToList();

                Assert.Single(footnoteFilterGroups);
                Assert.Equal(releaseSubject.SubjectId, footnoteFilterGroups[0].FilterGroup.Filter.SubjectId);

                var footnoteFilterItems = results[0].FilterItems.ToList();

                Assert.Single(footnoteFilterItems);
                Assert.Equal(releaseSubject.SubjectId, footnoteFilterItems[0].FilterItem.FilterGroup.Filter.SubjectId);

                var footnoteIndicators = results[0].Indicators.ToList();

                Assert.Single(footnoteIndicators);
                Assert.Equal(releaseSubject.SubjectId, footnoteIndicators[0].Indicator.IndicatorGroup.SubjectId);
            }
        }
Ejemplo n.º 16
0
        // Generates content of footnotesPart1.
        private void GenerateFootnotesPart1Content(FootnotesPart footnotesPart1)
        {
            Footnotes footnotes1 = new Footnotes(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 w15 wp14" }  };
            footnotes1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            footnotes1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            footnotes1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            footnotes1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            footnotes1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            footnotes1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            footnotes1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            footnotes1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            footnotes1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            footnotes1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2010/11/wordml");
            footnotes1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            footnotes1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            footnotes1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            footnotes1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Footnote footnote1 = new Footnote(){ Type = FootnoteEndnoteValues.Separator, Id = -1 };

            Paragraph paragraph6 = new Paragraph(){ RsidParagraphAddition = "006529C4", RsidParagraphProperties = "00157205", RsidRunAdditionDefault = "006529C4" };

            Run run9 = new Run();
            SeparatorMark separatorMark2 = new SeparatorMark();

            run9.Append(separatorMark2);

            paragraph6.Append(run9);

            footnote1.Append(paragraph6);

            Footnote footnote2 = new Footnote(){ Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0 };

            Paragraph paragraph7 = new Paragraph(){ RsidParagraphAddition = "006529C4", RsidParagraphProperties = "00157205", RsidRunAdditionDefault = "006529C4" };

            Run run10 = new Run();
            ContinuationSeparatorMark continuationSeparatorMark2 = new ContinuationSeparatorMark();

            run10.Append(continuationSeparatorMark2);

            paragraph7.Append(run10);

            footnote2.Append(paragraph7);

            Footnote footnote3 = new Footnote(){ Id = 1 };

            Paragraph paragraph8 = new Paragraph(){ RsidParagraphAddition = "003E4104", RsidRunAdditionDefault = "003E4104" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId(){ Val = "a3" };

            paragraphProperties1.Append(paragraphStyleId1);

            Run run11 = new Run();

            RunProperties runProperties7 = new RunProperties();
            RunStyle runStyle4 = new RunStyle(){ Val = "a5" };

            runProperties7.Append(runStyle4);
            FootnoteReferenceMark footnoteReferenceMark1 = new FootnoteReferenceMark();

            run11.Append(runProperties7);
            run11.Append(footnoteReferenceMark1);

            Run run12 = new Run();
            Text text4 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
            text4.Text = " ";

            run12.Append(text4);

            Run run13 = new Run();

            RunProperties runProperties8 = new RunProperties();
            RunFonts runFonts5 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties8.Append(runFonts5);
            Text text5 = new Text();
            text5.Text = "Reference 1";

            run13.Append(runProperties8);
            run13.Append(text5);

            paragraph8.Append(paragraphProperties1);
            paragraph8.Append(run11);
            paragraph8.Append(run12);
            paragraph8.Append(run13);

            footnote3.Append(paragraph8);

            Footnote footnote4 = new Footnote(){ Id = 2 };

            Paragraph paragraph9 = new Paragraph(){ RsidParagraphAddition = "003E4104", RsidRunAdditionDefault = "003E4104" };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId(){ Val = "a3" };

            paragraphProperties2.Append(paragraphStyleId2);

            Run run14 = new Run();

            RunProperties runProperties9 = new RunProperties();
            RunStyle runStyle5 = new RunStyle(){ Val = "a5" };

            runProperties9.Append(runStyle5);
            FootnoteReferenceMark footnoteReferenceMark2 = new FootnoteReferenceMark();

            run14.Append(runProperties9);
            run14.Append(footnoteReferenceMark2);

            Run run15 = new Run();
            Text text6 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
            text6.Text = " ";

            run15.Append(text6);

            Run run16 = new Run();

            RunProperties runProperties10 = new RunProperties();
            RunFonts runFonts6 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties10.Append(runFonts6);
            Text text7 = new Text();
            text7.Text = "Reference 2";

            run16.Append(runProperties10);
            run16.Append(text7);

            paragraph9.Append(paragraphProperties2);
            paragraph9.Append(run14);
            paragraph9.Append(run15);
            paragraph9.Append(run16);

            footnote4.Append(paragraph9);

            Footnote footnote5 = new Footnote(){ Id = 3 };

            Paragraph paragraph10 = new Paragraph(){ RsidParagraphAddition = "003E4104", RsidRunAdditionDefault = "003E4104" };

            ParagraphProperties paragraphProperties3 = new ParagraphProperties();
            ParagraphStyleId paragraphStyleId3 = new ParagraphStyleId(){ Val = "a3" };

            paragraphProperties3.Append(paragraphStyleId3);

            Run run17 = new Run();

            RunProperties runProperties11 = new RunProperties();
            RunStyle runStyle6 = new RunStyle(){ Val = "a5" };

            runProperties11.Append(runStyle6);
            FootnoteReferenceMark footnoteReferenceMark3 = new FootnoteReferenceMark();

            run17.Append(runProperties11);
            run17.Append(footnoteReferenceMark3);

            Run run18 = new Run();
            Text text8 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
            text8.Text = " ";

            run18.Append(text8);

            Run run19 = new Run();

            RunProperties runProperties12 = new RunProperties();
            RunFonts runFonts7 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties12.Append(runFonts7);
            Text text9 = new Text();
            text9.Text = "Reference 3";

            run19.Append(runProperties12);
            run19.Append(text9);

            paragraph10.Append(paragraphProperties3);
            paragraph10.Append(run17);
            paragraph10.Append(run18);
            paragraph10.Append(run19);

            footnote5.Append(paragraph10);

            footnotes1.Append(footnote1);
            footnotes1.Append(footnote2);
            footnotes1.Append(footnote3);
            footnotes1.Append(footnote4);
            footnotes1.Append(footnote5);

            footnotesPart1.Footnotes = footnotes1;
        }
        public async Task GetSubjectsWithNoFootnotes_FootnoteForMultipleSubjects()
        {
            var release = new Release();

            var releaseSubject1 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };
            var releaseSubject2 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };
            var releaseSubject3 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };
            var releaseSubject4 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };
            var releaseSubject5 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };
            var releaseSubjectWithNoFootnotes = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var footnote = new Footnote
            {
                Content  = "Test footnote 1",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject1.Subject,
                    }
                },
                Filters = new List <FilterFootnote>
                {
                    new FilterFootnote
                    {
                        Filter = new Filter
                        {
                            Subject = releaseSubject2.Subject
                        },
                    }
                },
                FilterGroups = new List <FilterGroupFootnote>
                {
                    new FilterGroupFootnote
                    {
                        FilterGroup = new FilterGroup
                        {
                            Filter = new Filter
                            {
                                Subject = releaseSubject3.Subject
                            },
                        }
                    }
                },
                FilterItems = new List <FilterItemFootnote>
                {
                    new FilterItemFootnote
                    {
                        FilterItem = new FilterItem
                        {
                            FilterGroup = new FilterGroup
                            {
                                Filter = new Filter
                                {
                                    Subject = releaseSubject4.Subject
                                },
                            }
                        }
                    }
                },
                Indicators = new List <IndicatorFootnote>
                {
                    new IndicatorFootnote
                    {
                        Indicator = new Indicator
                        {
                            IndicatorGroup = new IndicatorGroup
                            {
                                Subject = releaseSubject5.Subject
                            }
                        }
                    }
                }
            };

            var contextId = Guid.NewGuid().ToString();

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                await context.AddRangeAsync(release);

                await context.AddRangeAsync(
                    releaseSubject1,
                    releaseSubject2,
                    releaseSubject3,
                    releaseSubject4,
                    releaseSubject5,
                    releaseSubjectWithNoFootnotes
                    );

                await context.AddRangeAsync(footnote);

                await context.SaveChangesAsync();
            }

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                var repository = BuildFootnoteRepository(context);
                var results    = await repository.GetSubjectsWithNoFootnotes(release.Id);

                Assert.Single(results);

                Assert.Equal(releaseSubjectWithNoFootnotes.Subject.Id, results[0].Id);
            }
        }
Ejemplo n.º 18
0
        static StandardElementMapping()
        {
            foObjs       = new Hashtable();
            s_fObjMakers = new Dictionary <string, FObj.MakerBase>();

            // Declarations and Pagination and Layout Formatting Objects
            foObjs.Add("root", Root.GetMaker());
            foObjs.Add("declarations", Declarations.GetMaker());
            foObjs.Add("color-profile", ColorProfile.GetMaker());
            foObjs.Add("page-sequence", PageSequence.GetMaker());
            foObjs.Add("layout-master-set", LayoutMasterSet.GetMaker());
            foObjs.Add("page-sequence-master", PageSequenceMaster.GetMaker());
            foObjs.Add("single-page-master-reference", SinglePageMasterReference.GetMaker());
            foObjs.Add("repeatable-page-master-reference", RepeatablePageMasterReference.GetMaker());
            foObjs.Add("repeatable-page-master-alternatives", RepeatablePageMasterAlternatives.GetMaker());
            foObjs.Add("conditional-page-master-reference", ConditionalPageMasterReference.GetMaker());
            foObjs.Add("simple-page-master", SimplePageMaster.GetMaker());
            foObjs.Add("region-body", RegionBody.GetMaker());
            foObjs.Add("region-before", RegionBefore.GetMaker());
            foObjs.Add("region-after", RegionAfter.GetMaker());
            foObjs.Add("region-start", RegionStart.GetMaker());
            foObjs.Add("region-end", RegionEnd.GetMaker());
            foObjs.Add("flow", Flow.Flow.GetMaker());
            foObjs.Add("static-content", StaticContent.GetMaker());
            foObjs.Add("title", Title.GetMaker());

            // Block-level Formatting Objects
            foObjs.Add("block", Block.GetMaker());
            foObjs.Add("block-container", BlockContainer.GetMaker());

            // Inline-level Formatting Objects
            foObjs.Add("bidi-override", BidiOverride.GetMaker());
            foObjs.Add("character", Character.GetMaker());
            foObjs.Add("initial-property-set", InitialPropertySet.GetMaker());
            foObjs.Add("external-graphic", ExternalGraphic.GetMaker());
            foObjs.Add("instream-foreign-object", InstreamForeignObject.GetMaker());
            foObjs.Add("inline", Inline.GetMaker());
            foObjs.Add("inline-container", InlineContainer.GetMaker());
            foObjs.Add("leader", Leader.GetMaker());
            foObjs.Add("page-number", PageNumber.GetMaker());
            foObjs.Add("page-number-citation", PageNumberCitation.GetMaker());

            // Formatting Objects for Tables
            foObjs.Add("table-and-caption", TableAndCaption.GetMaker());
            foObjs.Add("table", Table.GetMaker());
            foObjs.Add("table-column", TableColumn.GetMaker());
            foObjs.Add("table-caption", TableCaption.GetMaker());
            foObjs.Add("table-header", TableHeader.GetMaker());
            foObjs.Add("table-footer", TableFooter.GetMaker());
            foObjs.Add("table-body", TableBody.GetMaker());
            foObjs.Add("table-row", TableRow.GetMaker());
            foObjs.Add("table-cell", TableCell.GetMaker());

            // Formatting Objects for Lists
            foObjs.Add("list-block", ListBlock.GetMaker());
            foObjs.Add("list-item", ListItem.GetMaker());
            foObjs.Add("list-item-body", ListItemBody.GetMaker());
            foObjs.Add("list-item-label", ListItemLabel.GetMaker());

            // Dynamic Effects: Link and Multi Formatting Objects
            foObjs.Add("basic-link", BasicLink.GetMaker());
            foObjs.Add("multi-switch", MultiSwitch.GetMaker());
            foObjs.Add("multi-case", MultiCase.GetMaker());
            foObjs.Add("multi-toggle", MultiToggle.GetMaker());
            foObjs.Add("multi-properties", MultiProperties.GetMaker());
            foObjs.Add("multi-property-set", MultiPropertySet.GetMaker());

            // Out-of-Line Formatting Objects
            foObjs.Add("float", Float.GetMaker());
            foObjs.Add("footnote", Footnote.GetMaker());
            foObjs.Add("footnote-body", FootnoteBody.GetMaker());

            // Other Formatting Objects
            foObjs.Add("wrapper", Wrapper.GetMaker());
            foObjs.Add("marker", Marker.GetMaker());
            foObjs.Add("retrieve-marker", RetrieveMarker.GetMaker());
        }
Ejemplo n.º 19
0
        public void AddFootnote()
        {
            //ExStart
            //ExFor:Footnote
            //ExFor:Footnote.IsAuto
            //ExFor:Footnote.ReferenceMark
            //ExFor:InlineStory
            //ExFor:InlineStory.Paragraphs
            //ExFor:InlineStory.FirstParagraph
            //ExFor:FootnoteType
            //ExFor:Footnote.#ctor
            //ExSummary:Shows how to insert and customize footnotes.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Add text, and reference it with a footnote. This footnote will place a small superscript reference
            // mark after the text that it references and create an entry below the main body text at the bottom of the page.
            // This entry will contain the footnote's reference mark and the reference text,
            // which we will pass to the document builder's "InsertFootnote" method.
            builder.Write("Main body text.");
            Footnote footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

            // If this property is set to "true", then our footnote's reference mark
            // will be its index among all the section's footnotes.
            // This is the first footnote, so the reference mark will be "1".
            Assert.True(footnote.IsAuto);

            // We can move the document builder inside the footnote to edit its reference text.
            builder.MoveTo(footnote.FirstParagraph);
            builder.Write(" More text added by a DocumentBuilder.");
            builder.MoveToDocumentEnd();

            Assert.AreEqual("\u0002 Footnote text. More text added by a DocumentBuilder.", footnote.GetText().Trim());

            builder.Write(" More main body text.");
            footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

            // We can set a custom reference mark which the footnote will use instead of its index number.
            footnote.ReferenceMark = "RefMark";

            Assert.False(footnote.IsAuto);

            // A bookmark with the "IsAuto" flag set to true will still show its real index
            // even if previous bookmarks display custom reference marks, so this bookmark's reference mark will be a "3".
            builder.Write(" More main body text.");
            footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

            Assert.True(footnote.IsAuto);

            doc.Save(ArtifactsDir + "InlineStory.AddFootnote.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "InlineStory.AddFootnote.docx");

            TestUtil.VerifyFootnote(FootnoteType.Footnote, true, string.Empty,
                                    "Footnote text. More text added by a DocumentBuilder.", (Footnote)doc.GetChild(NodeType.Footnote, 0, true));
            TestUtil.VerifyFootnote(FootnoteType.Footnote, false, "RefMark",
                                    "Footnote text.", (Footnote)doc.GetChild(NodeType.Footnote, 1, true));
            TestUtil.VerifyFootnote(FootnoteType.Footnote, true, string.Empty,
                                    "Footnote text.", (Footnote)doc.GetChild(NodeType.Footnote, 2, true));
        }
        public void AddFootnoteWithCustomMarks()
        {
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Some text");

            Footnote foot = new Footnote(doc, FootnoteType.Footnote);
            foot.ReferenceMark = "242";

            builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.", foot.ReferenceMark);

            MemoryStream dstStream = new MemoryStream();
            doc.Save(dstStream, SaveFormat.Docx);

            doc = new Document(dstStream);
            foot = (Footnote)doc.GetChildNodes(NodeType.Footnote, true)[0];
            
            Assert.IsFalse(foot.IsAuto);
            Assert.AreEqual("242", foot.ReferenceMark);
            Assert.AreEqual("242 Footnote text.\r", foot.GetText());
        }
        public override VisitorAction VisitFootnoteStart(Footnote footnote)
        {
            this.structureBuilder.AppendLine("<Footnote>");

            return VisitorAction.Continue;
        }
Ejemplo n.º 22
0
        internal void RepopulateFromCSLProcessor_SUCCESS(CSLProcessorOutputConsumer ip, CSLProcessor.BrowserThreadPassThru passthru)
        {
            int MAX_DODGY_PASTE_RETRY_COUNT     = 5;
            int DODGY_PASTE_RETRY_SLEEP_TIME_MS = 200;
            int dodgy_paste_retry_count         = 0;

            try
            {
                // Suppress screen updates (for performance reasons)
                repopulating_clusters           = true;
                word_application.ScreenUpdating = false;

                Document document = word_application.Selection.Document;

                // Get all the fields out there
                Logging.Info("+Enumerating all fields");
                List <Field> fields = GetDocumentFields(document);
                Logging.Info("-Enumerating all fields");

                StatusManager.Instance.ClearCancelled("InCite");
                for (int f = 0; f < fields.Count; ++f)
                {
                    if (StatusManager.Instance.IsCancelled("InCite"))
                    {
                        Logging.Info("Updating of citations in Word has been canceled by the user.");
                        break;
                    }
                    if (ShutdownableManager.Instance.IsShuttingDown)
                    {
                        Logging.Error("Canceling citation update in Word due to signaled Qiqqa application shutdown");
                        break;
                    }

                    Field field = fields[f];

                    StatusManager.Instance.UpdateStatus("InCite", "Updating InCite fields in Word", f, fields.Count, true);
                    word_application.StatusBar = String.Format("Updating InCite field {0} of {1}...", f, fields.Count);

                    try
                    {
                        // Do we have a citation that we can fill?
                        CitationCluster citation_cluster = GenerateCitationClusterFromField(field);
                        if (null != citation_cluster)
                        {
                            string text_for_cluster = ip.GetTextForCluster(citation_cluster.cluster_id);
                            string rtf_hash         = GenerateRTFHash(passthru.is_note_format, text_for_cluster);

                            // Update this citation cluster only if it needs updating (if it has changed from what is currently stored in it)
                            if (!String.IsNullOrEmpty(text_for_cluster))
                            {
                                bool needs_update = false;

                                if (!needs_update)
                                {
                                    if (rtf_hash != citation_cluster.rtf_hash)
                                    {
                                        needs_update = true;
                                    }
                                }

                                if (!needs_update)
                                {
                                    string current_field_contents = field.Result.Text;
                                    if (current_field_contents.Contains("QIQQA"))
                                    {
                                        needs_update = true;
                                    }
                                }

                                if (needs_update)
                                {
                                    // Update the field with the new hash
                                    citation_cluster.rtf_hash = rtf_hash;
                                    PopulateFieldWithRawCitationCluster(field, citation_cluster);

                                    // Remember the font
                                    string font_name = field.Result.Font.Name;
                                    float  font_size = field.Result.Font.Size;

                                    string rtf = RTF_START + text_for_cluster + RTF_END;
                                    ClipboardTools.SetText(rtf, TextDataFormat.Rtf);

                                    if (passthru.is_note_format)
                                    {
                                        field.Result.Text = "";
                                        Footnote footnote = field.Result.Footnotes.Add(field.Result);
                                        footnote.Range.Text = " ";
                                        Range range = footnote.Range;
                                        range.Collapse(WdCollapseDirection.wdCollapseStart);
                                        range.PasteSpecial(DataType: WdPasteDataType.wdPasteRTF);
                                        footnote.Range.Font.Name = font_name;
                                        footnote.Range.Font.Size = font_size;
                                    }
                                    else
                                    {
                                        field.Result.Text = " ";
                                        Range range = field.Result;
                                        range.Collapse(WdCollapseDirection.wdCollapseStart);
                                        range.PasteSpecial(DataType: WdPasteDataType.wdPasteRTF);
                                        field.Result.Text      = field.Result.Text.Trim();
                                        field.Result.Font.Name = font_name;
                                        field.Result.Font.Size = font_size;
                                    }
                                }
                            }
                            else
                            {
                                citation_cluster.rtf_hash = rtf_hash;
                                PopulateFieldWithRawCitationCluster(field, citation_cluster);
                                field.Result.Text = String.Format("ERROR: Unable to find key {0} in the CSL output.", citation_cluster.cluster_id);
                            }

                            // If we get here, it must have worked!
                            dodgy_paste_retry_count = 0;

                            continue;
                        }

                        // Do we have a bibliography that we can fill?
                        if (IsFieldBibliography(field))
                        {
                            // Remember the font
                            string font_name = field.Result.Font.Name;
                            float  font_size = field.Result.Font.Size;

                            string formatted_bibliography_section = ip.GetFormattedBibliographySection();
                            if (String.IsNullOrEmpty(formatted_bibliography_section))
                            {
                                formatted_bibliography_section = "Either this CSL citation style does not produce a bibliography section or you have not yet added any citations to this document, so this bibliography is empty.";
                            }

                            string formatted_bibliography_section_wrapped = CSLProcessorOutputConsumer.RTF_START + formatted_bibliography_section + CSLProcessorOutputConsumer.RTF_END;

                            ClipboardTools.SetText(formatted_bibliography_section_wrapped, TextDataFormat.Rtf);

                            field.Result.Text = " ";
                            Range range = field.Result;
                            range.Collapse(WdCollapseDirection.wdCollapseStart);
                            range.PasteSpecial(DataType: WdPasteDataType.wdPasteRTF);
                            field.Result.Font.Name = font_name;
                            field.Result.Font.Size = font_size;

                            // If we get here, it must have worked!
                            dodgy_paste_retry_count = 0;

                            continue;
                        }

                        // Do we have a CSL stats region?
                        if (IsFieldCSLStats(field))
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.Append(RTF_START);
                            {
                                sb.AppendFormat("maxoffset={0}\\line\n", ip.max_offset);
                                sb.AppendFormat("entryspacing={0}\\line\n", ip.entry_spacing);
                                sb.AppendFormat("linespacing={0}\\line\n", ip.line_spacing);
                                sb.AppendFormat("hangingindent={0}\\line\n", ip.hanging_indent);
                                sb.AppendFormat("second_field_align={0}\\line\n", ip.second_field_align);
                            }
                            sb.Append(RTF_END);

                            Clipboard.SetText(sb.ToString(), TextDataFormat.Rtf);

                            field.Result.Text = " ";
                            Range range = field.Result;
                            range.Collapse(WdCollapseDirection.wdCollapseStart);
                            range.PasteSpecial(DataType: WdPasteDataType.wdPasteRTF);

                            // If we get here, it must have worked!
                            dodgy_paste_retry_count = 0;

                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        ++dodgy_paste_retry_count;
                        if (dodgy_paste_retry_count < MAX_DODGY_PASTE_RETRY_COUNT)
                        {
                            Logging.Warn(ex, "Will try again (try {0}) because there was a problem updating a citation field: {1}", dodgy_paste_retry_count, field.Result.Text);

                            // Back up one field so we can try again
                            ShutdownableManager.Sleep(DODGY_PASTE_RETRY_SLEEP_TIME_MS);
                            --f;
                            continue;
                        }
                        else
                        {
                            Logging.Error(ex, "Giving up because there was a problem updating a citation field: {0}", field.Result.Text);
                            dodgy_paste_retry_count = 0;
                            continue;
                        }
                    }
                }
            }
            finally
            {
                // Restore the screen updates
                repopulating_clusters           = false;
                word_application.ScreenUpdating = true;
                word_application.StatusBar      = "Updated InCite fields.";
            }
        }
Ejemplo n.º 23
0
 // Paragraph
 internal virtual void VisitFootnote(Footnote footnote) { }
 //Paragraph
 internal virtual void VisitFootnote(Footnote footnote)
 {
 }
Ejemplo n.º 25
0
        // Generates content of footnotesPart1.
        private void GenerateFootnotesPart1Content(FootnotesPart footnotesPart1)
        {
            Footnotes footnotes1 = new Footnotes() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se wp14" } };
            footnotes1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            footnotes1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex");
            footnotes1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
            footnotes1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex");
            footnotes1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            footnotes1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            footnotes1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            footnotes1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            footnotes1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            footnotes1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            footnotes1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            footnotes1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            footnotes1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml");
            footnotes1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex");
            footnotes1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            footnotes1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            footnotes1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            footnotes1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Footnote footnote1 = new Footnote() { Type = FootnoteEndnoteValues.Separator, Id = -1 };

            Paragraph paragraph375 = new Paragraph() { RsidParagraphAddition = "00A563A2", RsidRunAdditionDefault = "00A563A2", ParagraphId = "07FB7F42", TextId = "77777777" };

            Run run763 = new Run();
            SeparatorMark separatorMark2 = new SeparatorMark();

            run763.Append(separatorMark2);

            paragraph375.Append(run763);

            footnote1.Append(paragraph375);

            Footnote footnote2 = new Footnote() { Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0 };

            Paragraph paragraph376 = new Paragraph() { RsidParagraphAddition = "00A563A2", RsidRunAdditionDefault = "00A563A2", ParagraphId = "7D479935", TextId = "77777777" };

            Run run764 = new Run();
            ContinuationSeparatorMark continuationSeparatorMark2 = new ContinuationSeparatorMark();

            run764.Append(continuationSeparatorMark2);

            paragraph376.Append(run764);

            footnote2.Append(paragraph376);

            Footnote footnote3 = new Footnote() { Type = FootnoteEndnoteValues.ContinuationNotice, Id = 1 };
            Paragraph paragraph377 = new Paragraph() { RsidParagraphAddition = "00A563A2", RsidRunAdditionDefault = "00A563A2", ParagraphId = "6E418186", TextId = "77777777" };

            footnote3.Append(paragraph377);

            footnotes1.Append(footnote1);
            footnotes1.Append(footnote2);
            footnotes1.Append(footnote3);

            footnotesPart1.Footnotes = footnotes1;
        }
        public async Task GetFootnotes_FiltersByRelease()
        {
            var release      = new Release();
            var otherRelease = new Release();

            var releaseSubject1 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var releaseSubject2 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var footnote1 = new Footnote
            {
                Content  = "Test footnote 1",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                    // Check that footnote is still fetched
                    // even if it also linked to another release
                    new ReleaseFootnote
                    {
                        Release = otherRelease
                    }
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject1.Subject
                    }
                },
            };

            var footnote2 = new Footnote
            {
                Content  = "Test footnote 2",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject2.Subject
                    }
                },
            };

            var footnoteForOtherRelease = new Footnote
            {
                Content  = "Test footnote for other release",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = new Release()
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = new Subject()
                    }
                },
            };

            var contextId = Guid.NewGuid().ToString();

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                await context.AddAsync(release);

                await context.AddRangeAsync(releaseSubject1, releaseSubject2);

                await context.AddRangeAsync(footnote1, footnote2, footnoteForOtherRelease);

                await context.SaveChangesAsync();
            }

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                var repository = BuildFootnoteRepository(context);
                var results    = repository.GetFootnotes(release.Id).ToList();

                Assert.Equal(2, results.Count);

                Assert.Equal("Test footnote 1", results[0].Content);

                var footnote1Releases = results[0].Releases.ToList();

                Assert.Single(footnote1Releases);
                Assert.Equal(release.Id, footnote1Releases[0].ReleaseId);

                var footnote1Subjects = results[0].Subjects.ToList();

                Assert.Single(footnote1Subjects);
                Assert.Equal(releaseSubject1.SubjectId, footnote1Subjects[0].SubjectId);

                Assert.Equal("Test footnote 2", results[1].Content);

                var footnote2Releases = results[1].Releases.ToList();

                Assert.Single(footnote2Releases);
                Assert.Equal(release.Id, footnote2Releases[0].ReleaseId);

                var footnote2Subjects = results[1].Subjects.ToList();
                Assert.Single(footnote2Subjects);
                Assert.Equal(releaseSubject2.SubjectId, footnote2Subjects[0].SubjectId);
            }
        }
Ejemplo n.º 27
0
        // Generates content of footnotesPart1.
        private void GenerateFootnotesPart1Content(FootnotesPart footnotesPart1)
        {
            Footnotes footnotes1 = new Footnotes() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } };
            footnotes1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            footnotes1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            footnotes1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            footnotes1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            footnotes1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            footnotes1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            footnotes1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            footnotes1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            footnotes1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            footnotes1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            footnotes1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            footnotes1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            footnotes1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Footnote footnote1 = new Footnote() { Type = FootnoteEndnoteValues.Separator, Id = -1 };

            Paragraph paragraph57 = new Paragraph() { RsidParagraphAddition = "00571FC0", RsidRunAdditionDefault = "00571FC0" };

            ParagraphProperties paragraphProperties55 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines45 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

            paragraphProperties55.Append(spacingBetweenLines45);

            Run run61 = new Run();
            SeparatorMark separatorMark2 = new SeparatorMark();

            run61.Append(separatorMark2);

            paragraph57.Append(paragraphProperties55);
            paragraph57.Append(run61);

            footnote1.Append(paragraph57);

            Footnote footnote2 = new Footnote() { Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0 };

            Paragraph paragraph58 = new Paragraph() { RsidParagraphAddition = "00571FC0", RsidRunAdditionDefault = "00571FC0" };

            ParagraphProperties paragraphProperties56 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines46 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

            paragraphProperties56.Append(spacingBetweenLines46);

            Run run62 = new Run();
            ContinuationSeparatorMark continuationSeparatorMark2 = new ContinuationSeparatorMark();

            run62.Append(continuationSeparatorMark2);

            paragraph58.Append(paragraphProperties56);
            paragraph58.Append(run62);

            footnote2.Append(paragraph58);

            footnotes1.Append(footnote1);
            footnotes1.Append(footnote2);

            footnotesPart1.Footnotes = footnotes1;
        }
        public async Task GetFootnotes_FiltersBySubjectIds()
        {
            var release = new Release();

            var releaseSubject1 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var releaseSubject2 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var releaseSubject3 = new ReleaseSubject
            {
                Release = release,
                Subject = new Subject()
            };

            var footnote1 = new Footnote
            {
                Content  = "Test footnote 1",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject1.Subject
                    }
                },
            };

            var footnote2 = new Footnote
            {
                Content  = "Test footnote 2",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject2.Subject
                    }
                },
            };

            var footnote3 = new Footnote
            {
                Content  = "Test footnote 3",
                Releases = new List <ReleaseFootnote>
                {
                    new ReleaseFootnote
                    {
                        Release = release
                    },
                },
                Subjects = new List <SubjectFootnote>
                {
                    new SubjectFootnote
                    {
                        Subject = releaseSubject3.Subject
                    }
                },
            };

            var contextId = Guid.NewGuid().ToString();

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                await context.AddAsync(release);

                await context.AddRangeAsync(releaseSubject1, releaseSubject2, releaseSubject3);

                await context.AddRangeAsync(footnote1, footnote2, footnote3);

                await context.SaveChangesAsync();
            }

            await using (var context = InMemoryStatisticsDbContext(contextId))
            {
                var repository = BuildFootnoteRepository(context);
                var results    = repository.GetFootnotes(
                    release.Id,
                    new List <Guid> {
                    releaseSubject1.SubjectId, releaseSubject3.SubjectId
                }
                    )
                                 .ToList();

                Assert.Equal(2, results.Count);

                Assert.Equal("Test footnote 1", results[0].Content);
                Assert.Equal("Test footnote 3", results[1].Content);
            }
        }
Ejemplo n.º 29
0
        // Generates content of footnotesPart1.
        private void GenerateFootnotesPart1Content(FootnotesPart footnotesPart1)
        {
            Footnotes footnotes1 = new Footnotes(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 w15 wp14" }  };
            footnotes1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            footnotes1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            footnotes1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            footnotes1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            footnotes1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            footnotes1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            footnotes1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            footnotes1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            footnotes1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            footnotes1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            footnotes1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2010/11/wordml");
            footnotes1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            footnotes1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            footnotes1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            footnotes1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Footnote footnote1 = new Footnote(){ Type = FootnoteEndnoteValues.Separator, Id = -1 };

            Paragraph paragraph25 = new Paragraph(){ RsidParagraphAddition = "00DC649D", RsidParagraphProperties = "00E930A2", RsidRunAdditionDefault = "00DC649D" };

            Run run31 = new Run();
            SeparatorMark separatorMark2 = new SeparatorMark();

            run31.Append(separatorMark2);

            paragraph25.Append(run31);

            footnote1.Append(paragraph25);

            Footnote footnote2 = new Footnote(){ Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0 };

            Paragraph paragraph26 = new Paragraph(){ RsidParagraphAddition = "00DC649D", RsidParagraphProperties = "00E930A2", RsidRunAdditionDefault = "00DC649D" };

            Run run32 = new Run();
            ContinuationSeparatorMark continuationSeparatorMark2 = new ContinuationSeparatorMark();

            run32.Append(continuationSeparatorMark2);

            paragraph26.Append(run32);

            footnote2.Append(paragraph26);

            footnotes1.Append(footnote1);
            footnotes1.Append(footnote2);

            footnotesPart1.Footnotes = footnotes1;
        }
Ejemplo n.º 30
0
 public virtual VisitorAction vmethod_29(Footnote A_0)
 {
     return(VisitorAction.Continue);
 }