Exemplo n.º 1
0
 public static bool checkTwoParagraphs(Paragraphs pg1, Paragraphs pg2)
 {
     if (pg1.Count == pg2.Count)
     {
         for (int i = 1; i <= pg1.Count; i++)
         {
             ABIW_Paragraph para1 = new ABIW_Paragraph(pg1[i]);
             ABIW_Paragraph para2 = new ABIW_Paragraph(pg2[i]);
             if (para1.Compare(para2).Result == ComparisonResultIndicate.equal)
             {
                 if (CompareTextRange(para1.Paragraph.Range, para2.Paragraph.Range))
                 {
                     continue;
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public CordovaProject(string title, Paragraphs description, List <BlogArticle> articles, List <SourceCode> sourceCode)
 {
     Title       = title;
     Description = description;
     Articles    = articles;
     SourceCode  = sourceCode;
 }
Exemplo n.º 3
0
        }                                                   // word paragraphs for expected results


        public TestStep(int stepNum, int stepWidth, int expectedWidth, Paragraphs stepParagraphs, Paragraphs expectedParagraphs)
        {
            /*
             * Load in the COM elements from the Doc
             * Arrange the Description into a Step
             * Set the expected result to the calculated spot
             */
            StepNumber     = stepNum;
            COMDescription = new List <WordParagraph>();
            COMExpected    = new List <WordParagraph>();
            foreach (var p in stepParagraphs.Cast <Paragraph>())
            {
                COMDescription.Add(new WordParagraph(p.Range, stepWidth));
            }
            foreach (var p in expectedParagraphs.Cast <Paragraph>())
            {
                COMExpected.Add(new WordParagraph(p.Range, expectedWidth));
            }

            SetRowNumbers(COMDescription);
            SetRowNumbers(COMExpected);
            SetStepDescription();
            SetExpected();
            SetTestSequence();
        }
        private void MarkTOCParagraphs()
        {
            // mark all paragraphs that will be indexed
            ProgressBar.Value = 0;

            Paragraphs myPars = new Paragraphs(tx);
            ArrayList  pars   = myPars.GetParagraphs();

            ProgressBar.Maximum = pars.Count;

            foreach (Paragraph curPar in pars)
            {
                ProgressBar.PerformStep();
                ProgressBar.Refresh();

                int styleCount = 1;

                foreach (string style in MatchList)
                {
                    if (curPar.Style == style)
                    {
                        TXTextControl.DocumentTarget newTarget =
                            new TXTextControl.DocumentTarget("target," +
                                                             styleCount.ToString() + "," + style + "," + curPar.Text + "," + curPar.Start.ToString());

                        tx.Select(curPar.Start, 0);
                        tx.DocumentTargets.Add(newTarget);
                    }

                    styleCount++;
                }
            }
        }
Exemplo n.º 5
0
        static void ToNextHeaderText(Paragraphs paragraphs)
        {
            Style style = null;

            foreach (Paragraph paragraph in paragraphs)
            {
                paragraphText = "";
                style         = paragraph.get_Style();
                if (
                    style.NameLocal == "Heading 1" ||
                    style.NameLocal == "Heading 2" ||
                    style.NameLocal == "Heading 3" ||
                    style.NameLocal == "Heading 4" ||
                    style.NameLocal == "Heading 5" ||
                    style.NameLocal == "Heading 6" ||
                    style.NameLocal == "Heading 7" ||
                    style.NameLocal == "Heading 8" ||
                    style.NameLocal == "Heading 9")
                {
                    Console.WriteLine("\n\n" + paragraph.Range.Text + "\n\n");
                }
                else
                {
                    paragraphText += paragraph.Range.Text;
                    Console.WriteLine(paragraphText);
                    continue;
                }
            }
        }
Exemplo n.º 6
0
        public int RemoveEmptyLines()
        {
            int count = Paragraphs.Count;

            if (count <= 0)
            {
                return(0);
            }

            int firstNumber = Paragraphs[0].Number;

            for (int i = Paragraphs.Count - 1; i >= 0; i--)
            {
                var p = Paragraphs[i];
                if (p.Text.IsOnlyControlCharactersOrWhiteSpace())
                {
                    Paragraphs.RemoveAt(i);
                }
            }
            if (count != Paragraphs.Count)
            {
                Renumber(firstNumber);
            }
            return(count - Paragraphs.Count);
        }
Exemplo n.º 7
0
        public string[] ValidateBookmarks(params string[] bookmarkNames)
        {
            var headers = new[] { Document.Headers.first, Document.Headers.even, Document.Headers.odd }.Where(h => h != null).ToList();
            var footers = new[] { Document.Footers.first, Document.Footers.even, Document.Footers.odd }.Where(f => f != null).ToList();

            var nonMatching = new List <string>();

            foreach (var bookmarkName in bookmarkNames)
            {
                if (headers.SelectMany(h => h.Paragraphs).Any(p => p.ValidateBookmark(bookmarkName)))
                {
                    return(new string[0]);
                }
                if (footers.SelectMany(h => h.Paragraphs).Any(p => p.ValidateBookmark(bookmarkName)))
                {
                    return(new string[0]);
                }
                if (Paragraphs.Any(p => p.ValidateBookmark(bookmarkName)))
                {
                    return(new string[0]);
                }
                nonMatching.Add(bookmarkName);
            }

            return(nonMatching.ToArray());
        }
Exemplo n.º 8
0
        /// <summary>
        /// Removes paragraphs by a list of IDs
        /// </summary>
        /// <param name="ids">IDs of paragraphs/lines to delete</param>
        /// <returns>Number of lines deleted</returns>
        public int RemoveParagraphsByIds(IEnumerable <string> ids)
        {
            int beforeCount = Paragraphs.Count;

            Paragraphs = Paragraphs.Where(p => !ids.Contains(p.Id)).ToList();
            return(beforeCount - Paragraphs.Count);
        }
Exemplo n.º 9
0
        public int CreateParagraph(string paragraphTitle)
        {
            Paragraph newParagraph = new Paragraph(paragraphTitle);

            Paragraphs.Add(newParagraph);
            return(Paragraphs.Count);
        }
Exemplo n.º 10
0
        /// <summary> 设置超链接 </summary>
        /// <param name="wdApp"></param>
        /// <remarks>此方法的要求是文本的排布格式要求:选择的段落格式必须是:
        /// 第一段为网页标题,第二段为网址;第三段为网页标题,第四段为网址……,
        /// 而且其中不能有空行,也不能选择空行</remarks>
        public static void SetHyperLink(Application wdApp)
        {
            var        sele = wdApp.Selection;
            Range      rg   = default(Range);
            Paragraphs Prs  = default(Paragraphs);

            rg  = sele.Range;
            Prs = rg.Paragraphs;
            //
            int   i      = 0;
            Range rgText = default(Range);
            Range rgURL  = default(Range);

            for (i = Prs.Count; i >= 1; i -= 2)
            {
                //索引标题段落
                rgText = Prs[i - 1].Range;
                //去掉末尾的回车符
                rgText.MoveEnd(Unit: WdUnits.wdCharacter, Count: -1);

                //索引网址段落并得到其文本
                rgURL = Prs[i].Range;
                wdApp.ActiveDocument.Hyperlinks.Add(Anchor: rgText, Address: rgURL.Text);

                //删除网址段落
                rgURL.Select();
                sele.Delete();
            }
        }
Exemplo n.º 11
0
 public BlogArticle(string title, string logo, Uri link, Paragraphs description)
 {
     Title       = title;
     Logo        = logo;
     Link        = link;
     Description = description;
 }
Exemplo n.º 12
0
        public string[] ValidateBookmarks(params string[] bookmarkNames)
        {
            var headers = Document.Headers.All.Where(h => h != null).ToList();
            var footers = Document.Footers.All.Where(f => f != null).ToList();

            var result = new List <string>();

            foreach (var bookmarkName in bookmarkNames)
            {
                if (headers.SelectMany(h => h.Paragraphs).Any(p => p.ValidateBookmark(bookmarkName)))
                {
                    return(new string[0]);
                }
                if (footers.SelectMany(h => h.Paragraphs).Any(p => p.ValidateBookmark(bookmarkName)))
                {
                    return(new string[0]);
                }
                if (Paragraphs.Any(p => p.ValidateBookmark(bookmarkName)))
                {
                    return(new string[0]);
                }
                result.Add(bookmarkName);
            }
            return(result.ToArray());
        }
Exemplo n.º 13
0
        public Table NewTable(int columLength)
        {
            Table table = Table.Create(columLength);

            Paragraphs.Add(table);

            return(table);
        }
Exemplo n.º 14
0
        public void GetSubshapeParagraphs()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Paragraphs response = TestUtils.SlidesApi.GetSubshapeParagraphs(c_fileName, c_slideIndex, c_shapePath,
                                                                            1, c_password, c_folderName);

            Assert.AreEqual(2, response.ParagraphLinks.Count);
        }
Exemplo n.º 15
0
        public void DeleteParagraph()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Paragraphs response = TestUtils.SlidesApi.DeleteParagraph(c_fileName, c_slideIndex, c_shapeIndex, 1,
                                                                      c_password, c_folderName);

            Assert.AreEqual(1, response.ParagraphLinks.Count);
        }
Exemplo n.º 16
0
        public void AddParagraph(string paragraphName)
        {
            var p = new Paragraph {
                TextAlignment = TextAlignment.Left, FontSize = 14
            };

            Document.Blocks.Add(p);
            Paragraphs.Add(paragraphName, p);
        }
Exemplo n.º 17
0
        public NSAttributedString AttributedStringForParagraph(XElement paragraph)
        {
            var returnValue = new NSMutableAttributedString();

            // TODO: find stage directions and format them differently
            if (ParagraphIsStageDirection(paragraph))
            {
                var stageDirection = new NSAttributedString(TextForParagraph(paragraph),
                                                            font: UIFont.FromName("Helvetica-LightOblique", 24),
                                                            paragraphStyle: new NSMutableParagraphStyle()
                {
                    Alignment = UITextAlignment.Center, LineSpacing = 10
                });
                returnValue.Append(stageDirection);
            }
            else
            {
                var speaker = new NSAttributedString(SpeakerForParagraph(paragraph),
                                                     font: UIFont.FromName("HoeflerText-Black", 24),
                                                     foregroundColor: UIColor.Brown
                                                     );
                var text = new NSAttributedString(TextForParagraph(paragraph),
                                                  font: UIFont.FromName("HoeflerText-Regular", 24.0f),
                                                  foregroundColor: UIColor.Black
#if TEST_OTHER_ATTRIBUTES
                                                  , backgroundColor: UIColor.Yellow,
                                                  ligatures: NSLigatureType.None,
                                                  kerning: 10,
                                                  underlineStyle: NSUnderlineStyle.Single,
                                                  shadow: new NSShadow()
                {
                    ShadowColor = UIColor.Red, ShadowOffset = new System.Drawing.SizeF(5, 5)
                },
                                                  strokeWidth: 5
#endif
                                                  );

                returnValue.Append(speaker, "  ", text);
            }

            if (Paragraphs.IndexOf(paragraph) == SelectedParagraph)
            {
                returnValue.AddAttribute(UIStringAttributeKey.ForegroundColor, UIColor.White, new NSRange(0, returnValue.Length));
                returnValue.AddAttribute(UIStringAttributeKey.BackgroundColor, UIColor.FromHSB(.6f, .6f, .7f), new NSRange(0, returnValue.Length));
            }

            returnValue.EnumerateAttribute(UIStringAttributeKey.ParagraphStyle, new NSRange(0, returnValue.Length), NSAttributedStringEnumeration.LongestEffectiveRangeNotRequired,
                                           (NSObject value, NSRange range, ref bool stop) => {
                var style = value == null ? new NSMutableParagraphStyle() : (NSMutableParagraphStyle)value.MutableCopy();
                style.MinimumLineHeight = LineHeight;
                style.MaximumLineHeight = LineHeight;

                returnValue.AddAttribute(UIStringAttributeKey.ParagraphStyle, style, range);
            });

            return(returnValue);
        }
Exemplo n.º 18
0
 public SummaryTile(string title, Paragraphs description, string action, string controller, string linkName, string iconClass = null)
 {
     Title       = title;
     Description = description;
     Action      = action;
     Controller  = controller;
     LinkName    = linkName;
     IconClass   = iconClass;
 }
 protected override void CleanupUnmanagedResources()
 {
     if (Paragraphs != null)
     {
         Paragraphs.Clear();
     }
     Owner = null;
     base.CleanupUnmanagedResources();
 }
Exemplo n.º 20
0
        public void DeleteSubshapeParagraphsIndexes()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Paragraphs response = TestUtils.SlidesApi.DeleteSubshapeParagraphs(c_fileName, c_slideIndex, c_shapePath, 1,
                                                                               new List <int> {
                1
            }, c_password, c_folderName);

            Assert.AreEqual(1, response.ParagraphLinks.Count);
        }
Exemplo n.º 21
0
 private static void ProcessParagraphs(Paragraphs paragraphs, XmlWriter xmlw)
 {
     xmlw.WriteStartElement("Paragraphs");
     xmlw.WriteAttributeString("Count", paragraphs.Count.ToStringSafe());
     foreach (Paragraph p in paragraphs)
     {
         ProcessParagraph(p, xmlw);
     }
     xmlw.WriteEndElement();
 }
Exemplo n.º 22
0
        public ActionResult Edit(Node node, int ParentNodeID = -1, int TreeLevel = -1)
        {
            int           LinesNoOf, SentencesNoOf, ParagraphsNoOf;
            List <string> lines, sentences, paragrphs, newParagraphs;
            Paragraphs    paragraphs;
            List <int>    SentenceInParagraph;

            SentenceInParagraph = new List <int>();
            paragrphs           = new List <string>();
            sentences           = new List <string>();
            lines         = new List <string>();
            newParagraphs = new List <string>();
            paragraphs    = new Paragraphs();

            ViewBag.SelectedNodeHeading = node.Heading;

            paragraphs.TheText = node.NodeText;

            paragraphs.NoOfChars = paragraphs.TheText.Length;
            paragraphs.Paragrphs(out ParagraphsNoOf, ref paragrphs, out SentencesNoOf, ref sentences, ref SentenceInParagraph, out LinesNoOf, ref lines, 0, false, true, true, false, true, false, false);

            node.NodeText = paragraphs.TheAlteredText;

            if (ParentNodeID != -1)
            {
                node.TreeID       = 2;
                node.TypeID       = 5;
                node.ParentNodeID = ParentNodeID;
                node.TreeLevel    = (short)TreeLevel;
            }
            if (ModelState.IsValid)
            {
                if (node.Heading.Length > 50)
                {
                    node.Heading = node.Heading.Substring(0, 50);
                }
                ;
                if (node.NodeID == 0)
                {
                    repository.Edit(node);
                    TempData["message"] = string.Format("Node: {0}, {1} ... has been created", node.NodeID, node.Heading);
                }
                else
                {
                    repository.Edit(node);
                    TempData["message"] = string.Format("Node: {0}, {1} ... has been edited", node.NodeID, node.Heading);
                }
                return(RedirectToAction("Index", "Book", new { NodeID = node.NodeID }));
            }
            else
            {
                // there is something wrong with the data values
                return(View(node));
            }
        }
Exemplo n.º 23
0
        private void ParseRows(XElement tbody, Table table, TableAnalyzer tableAnalyzer)
        {
            List <decimal> cellWidthPercentages = tableAnalyzer.CellWidthPercentages;
            List <decimal> tableCellWidthSums   = tableAnalyzer.TableCellWidthSums;

            for (int r = 1; r <= table.Rows.Count; r++)
            {
                var currentRow = new XElement("tr");
                tbody.Add(currentRow);
                decimal currentWidthSum = 0;
                int     numColSpansUsed = 0;
                for (int c = 1; c <= table.Columns.Count; c++)
                {
                    try
                    {
                        var curCell = table.Cell(r, c);
                        curCell.Select();
                        var       app       = curCell.Application;
                        Selection selection = app.Selection;
                        var       xmlCell   = new XElement(@"td");
                        currentRow.Add(xmlCell);
                        Paragraphs paragraphs            = curCell.Range.Paragraphs;
                        var        tableBuilder          = new TableBuilder(curCell.Tables);
                        var        paragraphsTransformer = new TableCellParagraphsTransformer(paragraphs);
                        PopulateTableCell(xmlCell, paragraphsTransformer, tableBuilder);
                        currentWidthSum += (decimal)curCell.Width;
                        int widthIndex             = tableCellWidthSums.IndexOf(currentWidthSum);
                        int currentNumberOfColumns = widthIndex + 1 - numColSpansUsed;
                        SetTableCellAttributes(xmlCell, widthIndex, currentNumberOfColumns, cellWidthPercentages, selection);
                        numColSpansUsed += currentNumberOfColumns;
                    }
                    catch (System.Runtime.InteropServices.COMException)
                    {                     //it seems that the only way to tell if a cell at a particular [row, col] index
                        //exists is to call table.Cell(row, col) and see if it throws an exception
                        //the reason it may not exist is rowspans and colspans
                        int nr = r;
                        while (nr > 0)
                        {
                            try
                            {
                                currentWidthSum += (decimal)table.Cell(nr, c).Width;
                                int widthIndex = tableCellWidthSums.IndexOf(currentWidthSum);
                                int curNumCol  = widthIndex + 1 - numColSpansUsed;
                                numColSpansUsed += curNumCol;
                                break;
                            }
                            catch (System.Runtime.InteropServices.COMException)
                            {
                                nr--;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Starting a new Document Section after the last paragraph in the Document Body. Document Body must contain at least one paragraph.
        /// </summary>
        public void StartNewSection(SectionBreakType?sectionBreakType = null)
        {
            var lastParagraph = Paragraphs.LastOrDefault() ??
                                throw new InvalidOperationException("Body must contain at least one paragraph to start a new section");

            var sectPr = new XElement(LastSectionProperties.Xml);

            lastParagraph.Properties.SetSectionProperties(sectPr);

            LastSectionProperties.Xml.SetSingleElementAttributeOrRemoveElement("type", "val", sectionBreakType?.ToCamelCase());
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates a numbered list for the document.
        /// </summary>
        /// <returns></returns>
        public NumberedList AddNumberedList()
        {
            //Get the new index
            int index = GetNewIndex();
            //Add the list
            NumberedList list = new NumberedList();

            Paragraphs.Add(index, list);

            return(list);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Adds a new paragrah with a header and text with a give style for the header and the paragraph.
        /// </summary>
        /// <param name="headerText">The header of the paragrah</param>
        /// <param name="text">The text of the paragraph</param>
        /// <param name="paragraphStyle">The style of the paragraph</param>
        /// <param name="headerStyle">The style of the header</param>
        /// <param name="id">The id (name) of the paragraph</param>
        public NamedParagraph AddNamedParagraph(string text, string headerText, string paragraphStyle, string headerStyle, string id)
        {
            //Get the new index
            var index = GetNewIndex();
            //Now add the paragraph
            var paragraph = new NamedParagraph(text, headerText, paragraphStyle, headerStyle, id);

            Paragraphs.Add(index, paragraph);

            return(paragraph);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Adds a picture to the document
        /// </summary>
        /// <param name="filePath">The path to the image to add</param>
        /// <param name="title">The title of the image</param>
        /// <returns>An picture object</returns>
        public Picture AddPicture(string filePath, string title)
        {
            //Get the new index
            int index = GetNewIndex();
            //Add the picture
            Picture picture = new Picture(filePath, title, 0);

            Paragraphs.Add(index, picture);

            return(picture);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Adds a table to the document
        /// </summary>
        /// <param name="title">The title of the table</param>
        /// <returns>A table</returns>
        public Table AddTable(string title)
        {
            //Get the new index
            int index = GetNewIndex();
            //Add the table
            Table table = new Table(title, 0);

            Paragraphs.Add(index, table);

            return(table);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Adds a new paragrah to the document on a given heading level.
        /// </summary>
        /// <param name="text">The text of the paragraph</param>
        /// <param name="headingLevel">The level of the paragraph</param>
        /// <returns>The paragraph without the header</returns>
        public Paragraph AddParagraph(string text, int headingLevel)
        {
            //Get the new index
            var index = GetNewIndex();
            //Now add the paragraph
            var paragraph = new Paragraph(text, headingLevel);

            Paragraphs.Add(index, paragraph);

            return(paragraph);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates a bullet list for the document.
        /// </summary>
        /// <returns></returns>
        public BulletList AddBulletList()
        {
            //Get the new index
            int index = GetNewIndex();
            //Add the list
            BulletList list = new BulletList();

            Paragraphs.Add(index, list);

            return(list);
        }
Exemplo n.º 31
0
    Paragraphs.Question[] shuffle(Paragraphs.Question[] tempArray)
    {
        int n = tempArray.Length;

        for (int i = 0; i < n; i++) {
            int r = UnityEngine.Random.Range (i, n);
            Paragraphs.Question temp = tempArray[i];
            tempArray[i] = tempArray[r];
            tempArray[r] = temp;
        }

        return tempArray;
    }
        public void LoadDocument(string Path)
        {
            try
            {
                document = new Dock(DocumentMode.Load, Path);

                object findText = "И все случайности,  которые,  случившись,  становятся  причиной  других случайностей, становятся причиной других случайностей.";
                object replaceText = "ТЕСТ пройден";
                FindAndReplace(document.App, findText, replaceText);

                paragraphs = document.Document.Paragraphs;
                text = "";// document.Document.Content.Text;

                foreach (Paragraph p in paragraphs)
                {
                    text += p.Range.Text + "\n";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }