Exemple #1
0
    public void UpdateInteractable()
    {
        Bookmark bookmark = new Bookmark(suggestedTitle, BookmarkTargets.Select(x => BookmarkData.Create(x)).ToArray());

        dropdown.Interactable = !UIParent.Data.HasBookmark(bookmark);
        hasBookmarkGraphic.SetActive(!dropdown.Interactable);
    }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateBookmarkRequest"/> class.
 /// </summary>
 /// <param name="name">The filename of the input document.</param>
 /// <param name="bookmarkName">The name of the bookmark.</param>
 /// <param name="bookmarkData">Bookmark data.</param>
 /// <param name="folder">Original document folder.</param>
 /// <param name="storage">Original document storage.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param>
 /// <param name="revisionDateTime">The date and time to use for revisions.</param>
 public UpdateBookmarkRequest(string name, string bookmarkName, BookmarkData bookmarkData, string folder = null, string storage = null, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null)
 {
     this.Name             = name;
     this.BookmarkName     = bookmarkName;
     this.BookmarkData     = bookmarkData;
     this.Folder           = folder;
     this.Storage          = storage;
     this.LoadEncoding     = loadEncoding;
     this.Password         = password;
     this.DestFileName     = destFileName;
     this.RevisionAuthor   = revisionAuthor;
     this.RevisionDateTime = revisionDateTime;
 }
 public BookmarkData[] GetBookmarks()
 {
     XmlDocument doc = CheckFile(FilePath, FolderPath);
     List<BookmarkData> toReturn = new List<BookmarkData>();
     for (int i = 0; i < doc.ChildNodes[1].ChildNodes.Count; i++)
     {
         BookmarkData bd = new BookmarkData();
         bd.Name = doc.ChildNodes[1].ChildNodes[i].Attributes[0].Value;
         bd.Path = doc.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerText;
         toReturn.Add(bd);
     }
     return toReturn.ToArray();
 }
        public BookmarkData[] GetBookmarks()
        {
            XmlDocument         doc      = CheckFile(FilePath, FolderPath);
            List <BookmarkData> toReturn = new List <BookmarkData>();

            for (int i = 0; i < doc.ChildNodes[1].ChildNodes.Count; i++)
            {
                BookmarkData bd = new BookmarkData();
                bd.Name = doc.ChildNodes[1].ChildNodes[i].Attributes[0].Value;
                bd.Path = doc.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerText;
                toReturn.Add(bd);
            }
            return(toReturn.ToArray());
        }
 public void DeleteBookmark(BookmarkData Bookmark)
 {
     XmlDocument doc = CheckFile(FilePath, FolderPath);
     for (int i = 0; i < doc.ChildNodes[1].ChildNodes.Count; i++)
     {
         BookmarkData bd = new BookmarkData();
         bd.Name = doc.ChildNodes[1].ChildNodes[i].Attributes[0].Value;
         bd.Path = doc.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerText;
         if (bd.Name == Bookmark.Name && bd.Path == Bookmark.Path)
         {
             doc.ChildNodes[1].RemoveChild(doc.ChildNodes[1].ChildNodes[i]);
             doc.Save(FilePath);
             break;
         }
     }
 }
 public bool CheckIfBookmarkExists(string Name, string Path)
 {
     XmlDocument doc = CheckFile(FilePath, FolderPath);
     for (int i = 0; i < doc.ChildNodes[1].ChildNodes.Count; i++)
     {
         BookmarkData bd = new BookmarkData();
         bd.Name = doc.ChildNodes[1].ChildNodes[i].Attributes[0].Value;
         bd.Path = doc.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerText;
         if (bd.Name == Name && bd.Path == Path)
         {
             doc.ChildNodes[1].ChildNodes[i].RemoveChild(doc.ChildNodes[1].ChildNodes[i]);
             return true;
         }
     }
     return false;
 }
        public bool CheckIfBookmarkExists(string Name, string Path)
        {
            XmlDocument doc = CheckFile(FilePath, FolderPath);

            for (int i = 0; i < doc.ChildNodes[1].ChildNodes.Count; i++)
            {
                BookmarkData bd = new BookmarkData();
                bd.Name = doc.ChildNodes[1].ChildNodes[i].Attributes[0].Value;
                bd.Path = doc.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerText;
                if (bd.Name == Name && bd.Path == Path)
                {
                    doc.ChildNodes[1].ChildNodes[i].RemoveChild(doc.ChildNodes[1].ChildNodes[i]);
                    return(true);
                }
            }
            return(false);
        }
        public void DeleteBookmark(BookmarkData Bookmark)
        {
            XmlDocument doc = CheckFile(FilePath, FolderPath);

            for (int i = 0; i < doc.ChildNodes[1].ChildNodes.Count; i++)
            {
                BookmarkData bd = new BookmarkData();
                bd.Name = doc.ChildNodes[1].ChildNodes[i].Attributes[0].Value;
                bd.Path = doc.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerText;
                if (bd.Name == Bookmark.Name && bd.Path == Bookmark.Path)
                {
                    doc.ChildNodes[1].RemoveChild(doc.ChildNodes[1].ChildNodes[i]);
                    doc.Save(FilePath);
                    break;
                }
            }
        }
        public void TestPostUpdateDocumentBookmark()
        {
            var localName    = "test_multi_pages.docx";
            var remoteName   = "TestGetDocumentBookmarkByName.docx";
            var fullName     = Path.Combine(this.dataFolder, remoteName);
            var bookmarkName = "aspose";
            var destFileName = Path.Combine(BaseTestOutPath, remoteName);
            var body         = new BookmarkData {
                Name = bookmarkName, Text = "This will be the text for Aspose"
            };

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName));

            var request = new PostUpdateDocumentBookmarkRequest(remoteName, body, bookmarkName, this.dataFolder, destFileName: destFileName);
            var actual  = this.WordsApi.PostUpdateDocumentBookmark(request);

            Assert.AreEqual(200, actual.Code);
        }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateBookmarkOnlineRequest"/> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="bookmarkName">The name of the bookmark.</param>
 /// <param name="bookmarkData">Bookmark data.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param>
 /// <param name="revisionDateTime">The date and time to use for revisions.</param>
 public UpdateBookmarkOnlineRequest(System.IO.Stream document, string bookmarkName, BookmarkData bookmarkData, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null)
 {
     this.Document         = document;
     this.BookmarkName     = bookmarkName;
     this.BookmarkData     = bookmarkData;
     this.LoadEncoding     = loadEncoding;
     this.Password         = password;
     this.DestFileName     = destFileName;
     this.RevisionAuthor   = revisionAuthor;
     this.RevisionDateTime = revisionDateTime;
 }
Exemple #11
0
    // On click, try to add the bookmark
    // If adding the bookmark succeeds, then make the bookmark UI create a new bookmark
    protected virtual void TryAddBookmark()
    {
        Bookmark bookmark = new Bookmark(bookmarkTitle.text, BookmarkTargets.Select(x => BookmarkData.Create(x)).ToArray());

        if (UIParent.Data.TryAddBookmark(bookmark))
        {
            bookmarkUI.CreateBookmarkButton(bookmark);
            dropdown.DisableDropdown();

            // Update interactable state of the button
            UpdateInteractable();
        }
    }