Esempio n. 1
2
        public HumanMacroDialog(Word.Range text, int jobNumber)
        {
            this.text = text;
            this.jobNumber = jobNumber;
            InitializeComponent();

            Binding binding = new Binding();
            binding.Source = text;
            binding.Path = new PropertyPath("Text");
            textToWorkWith.SetBinding(TextBox.TextProperty, binding);

            numItems.Content = numSections + " paragraph" + (numSections == 1 ? "" : "s") + " selected, each as a separate task";

            item1 = new ComboBoxItem();
            item1.Content = "Paragraph";
            item2 = new ComboBoxItem();
            item2.Content = "Sentence";

            separatorBox.Items.Add(item1);
            separatorBox.Items.Add(item2);
            separatorBox.SelectedValue = item1;

            returnAsComments = new ComboBoxItem();
            returnAsComments.Content = "Comments";
            returnAsInline = new ComboBoxItem();
            returnAsInline.Content = "In-Line Changes";
            returnTypeBox.Items.Add(returnAsComments);
            returnTypeBox.Items.Add(returnAsInline);
            returnTypeBox.SelectedValue = returnAsComments;
        }
Esempio n. 2
1
 protected Wd.ContentControl AddDetailsControl(Wd.Range range)
 {
     var detailsControl = range.ContentControls.Add_Safely(Wd.WdContentControlType.wdContentControlText);
     detailsControl.Title = control.Title + " Details";
     detailsControl.Tag = control.Tag.Remove(" Delivery") + " Details";
     return detailsControl;
 }
Esempio n. 3
1
        public UrlListForm(Word.Document doc)
        {
            InitializeComponent();

            if (doc == null)
                return;
            wordDoc = doc;

            hyperlink_urls = WordUrlManager.GetListOfHyperlinkUrls(doc);
            hyperlink_requests = new HttpWebRequest[hyperlink_urls.Length];
            autofind_urls = WordUrlManager.GetListOfAllUrls(doc);
            autofind_requests = new HttpWebRequest[autofind_urls.Length];
            active_urls = hyperlink_urls;
            active_requests = hyperlink_requests;

            InitializeUrlViewList();

            progressBar.Visible = true;
            if (active_urls.Length == 0)
                progressBar.Visible = false;
            progressBar.Minimum = 0;
            progressBar.Maximum = active_urls.Length;
            progressBar.Step = 1;
            progressBar.Value = 0;

            button_RecheckEveryURL.Enabled = false;
            radioButton_autofindUrls.Enabled = false;
            radioButton_wordHyperlinks.Enabled = false;
            listView.BeginUpdate();

            urlTesterThread = null;
            RestartTestingThread = null;
            urlTesterThread_shouldStop = false;
        }
Esempio n. 4
0
        /// <summary>
        /// A superclass that represents the Model for an individual HIT.
        /// </summary>
        /// <param name="range">The Range object selected for this task</param>
        /// <param name="job">The unique job number for this task</param>
        public HITData(Word.Range range, int job)
        {
            this.range = range;
            this.job = job;
            int unixTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
            string bookmarkName = "Soylent" + job;
            this.stages = new List<StageData>();

            numParagraphs = range.Paragraphs.Count;

            //stages = new Dictionary<ResultType, StageData>();
            //TODO: Use Word XML binding to text instead of bookmarks.
            /*
             * Improved Data Mapping Provides Separation Between a Document's Data and Its Formatting
             *  XML mapping allows you to attach XML data to Word documents and link XML elements to placeholders in the document.
             *  Combined with content controls, XML mapping becomes a powerful tool for developers.
             *  These features provide you with the capability to position content controls in the document and then link them to XML elements.
             *  This type of data and view separation allows you to access Word document data to repurpose and integrate with other systems and applications.
             */

            object bkmkRange = (object)range;
            Globals.Soylent.jobToDoc[this.job].Bookmarks.Add(bookmarkName, ref bkmkRange);

            tk = new TurKit(this);
        }
Esempio n. 5
0
 public void showHome(Word.Application WordApp)
 {
     this.UseWordApp = WordApp;
     this.webBrowser1.ObjectForScripting = this;
     this.webBrowser1.Navigate(new Uri("http://localhost:8080/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/office/my_alfresco.ftl&contextPath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/office/my_alfresco.ftl"));
     //this.webBrowser1.Navigate(new Uri("http://www.alfresco.com"));
 }
 public static Wd.TableOfContents Add(this Wd.TablesOfContents tocs, Wd.Range range)
 {
     range.Fields.Add(range, Wd.WdFieldType.wdFieldTOC, string.Format(@"\b ""{0}"" \o ""1-1"" \h \z ", Bookmark_TOCRange), false);
     Wd.TableOfContents toc = tocs[tocs.Count];
     toc.TabLeader = Wd.WdTabLeader.wdTabLeaderDots;
     return toc;
 }
        public Wd.Range UpdateControls(IList<Contact> contacts, Wd.WdCollapseDirection CollapseDirection = Wd.WdCollapseDirection.wdCollapseEnd)
        {
            try
            {
                var control = doc.ContentControls(x => x.Tag == controlTags.First()).First();
                var range = control.ParentContentControl.Range;
                range.MoveEnd(Wd.WdUnits.wdParagraph, 1);
                range.Copy();

                range.ContentControls.DeleteEmpty();
                range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd);
                for (int i = 2; i <= contacts.Count; i++)
                {
                    range.MoveOutOfContentControl();
                    range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd);
                    range.Paste();
                    UpdateContentControlMappings(range, i);
                    range.ContentControls.DeleteEmpty();
                }
                range = range.CollapseEnd();
                if (range.Paragraphs[1].IsEmpty())
                    range.Paragraphs[1].Range.Delete();

                doc.Bookmarks.DeleteIfExists(Bookmarks);
                UpdateDeliveryDetails();

                range.Move(Wd.WdUnits.wdCharacter, 1);
                return range;
            }
            finally
            {
                ClipboardHelper.Clear();
            }
        }
 public static Wd.ContentControl Add(this Wd.ContentControls controls, string PlaceholderText, Wd.WdContentControlType type = Wd.WdContentControlType.wdContentControlRichText, bool Temporary = true)
 {
     var control = controls.Add(type);
     control.SetPlaceholderText(null, null, PlaceholderText);
     control.Temporary = Temporary;
     return control;
 }
        public FormFormatDate(Word.ContentControl currentCC)
        {
            InitializeComponent();

            this.currentCC = currentCC;

            if (currentCC.XMLMapping.IsMapped)
            {
                String dateValue = currentCC.XMLMapping.CustomXMLNode.Text;
                if (!DateTime.TryParse(dateValue, out thisDate1)) {
                    thisDate1 = DateTime.Now;
                    }
            }
            else
            {
                thisDate1 = DateTime.Now;
            }

            for (int i = 0; i < formatValues.Length; i++)
            {
                FormatChoice fc = new FormatChoice();
                fc.format = formatValues[i];
                fc.display = thisDate1.ToString(fc.format);
                this.listBoxFormat.Items.Add(fc);
            }

            if (currentCC.DateDisplayFormat != null)
            {
                this.textBoxFormat.Text = currentCC.DateDisplayFormat;
            }
        }
 public WordUrlManager(Word.Application wordApp)
 {
     Word.Options options = wordApp.Application.Options;
     originalSettings_ReplaceHyperlinks = options.AutoFormatReplaceHyperlinks;
     originalSettings_AsYouTypeReplaceHyperlinks = options.AutoFormatAsYouTypeReplaceHyperlinks;
     wordAppOptionsChanged = false;
 }
        private WorkContact CreateContact(Word.Row row, WorkGroup latestGroup)
        {
            try
            {
                //Trainers, Misc and Office have strange formats so don't do them
                if (latestGroup != WorkGroup.Trainer && latestGroup != WorkGroup.Misc && latestGroup != WorkGroup.Office)
                {
                    string nameAndInitials = GetNameAndInitials(row);
                    string[] nameFields = nameAndInitials.Split(' ');
                    string firstname = GetFirstName(nameFields);
                    string surname = GetSurname(nameFields);
                    string initials = GetInitials(nameFields);
                    string mobile = GetMobileNumber(row);
                    string home = GetHomeNumber(row);

                    //if there is at least one number then we can reasonably assume it's a contact
                    if (!string.IsNullOrWhiteSpace(mobile) || !string.IsNullOrWhiteSpace(home))
                    {
                        return WorkContact.FactoryCreate(firstname, surname, initials, mobile, home, latestGroup);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Had the following exception: " + e.Message);
                Console.WriteLine(e.StackTrace);
            }
            return null;
        }
Esempio n. 12
0
        public string collectWord(Word.Document doc)
        {
            doc.ActiveWindow.Selection.WholeStory();
            string str = doc.ActiveWindow.Selection.Text;

            return analyze(str);
        }
 //private static Word.Application wordapp = new Word.Application();
 public static Document OpenDocument(Word.Application wordapp, string fileName)
 {
     wordapp.Visible = true;
     //Setting for open
     string FileName = fileName;
     bool ConfirmConversions = false;
     bool ReadOnly = false;
     bool AddToRecentFiles = false;
     object PasswordDocument = missing;
     object PasswordTemplate = missing;
     bool Revert = false;
     object WritePasswordDocument = missing;
     object WritePasswordTemplate = missing;
     object Format = missing;
     object Encoding = missing;
     bool Visible = true;
     bool OpenAndRepair = true;
     object DocumentDirection = missing;
     bool NoEncodingDialog = false;
     object XMLTransform = missing;
     //
     return  wordapp.Documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
                                                 PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
                                                 WritePasswordTemplate, Format, Encoding, Visible, OpenAndRepair,
                                                 DocumentDirection = missing, NoEncodingDialog, XMLTransform);
 }
Esempio n. 14
0
 static void DeleteParagraphIfEmpty1(Wd.ContentControl control)
 {
     Wd.Range range = control.Range;
     control.Delete(true);
     if (range.Paragraphs[1].IsEmpty())
         range.Paragraphs[1].Range.Delete();
 }
Esempio n. 15
0
 public void AddTable(word.Application wdapp, word.Document wddoc, OracleConnection oracon, string strsql, string title = null)
 {
     OracleDataAdapter oda = new OracleDataAdapter(strsql, oracon);
     DataTable dt = new DataTable();
     oda.Fill(dt);
     this.AddTable(wdapp, wddoc, dt, null, null, title);
 }
Esempio n. 16
0
		protected bool ProcessParagraphs(OfficeDocumentProcessor aWordProcessor, Word.Paragraphs aParagraphs)
		{
			foreach (Word.Paragraph aParagraph in aParagraphs)
			{
				// get the Range object for this paragraph
				Word.Range aParagraphRange = aParagraph.Range;

				// if we're picking up where we left off and we're not there yet...
				int nCharIndex = 0;
				if (aWordProcessor.AreLeftOvers)
				{
					if (aWordProcessor.LeftOvers.Start > aParagraphRange.End)
						continue;   // skip to the next paragraph

					nCharIndex = aWordProcessor.LeftOvers.StartIndex;
					aWordProcessor.LeftOvers = null; // turn off "left overs"
				}

				WordRange aThisParagraph = new WordRange(aParagraphRange);
				if (!ProcessRangeAsWords(aWordProcessor, aThisParagraph, nCharIndex))
					return false;
			}

			return true;
		}
        public Word.ContentControl getRepeatAncestor(Word.ContentControl cc)
        {
            Word.ContentControl repeatAncestor = null;

            if (root != null
                && !treeViewRepeat.SelectedNode.Equals(root)) // this varies with some repeat
            {
                // Which one is checked?
                string variesInRepeatId = (string)treeViewRepeat.SelectedNode.Tag;

                Word.ContentControl currentCC = cc.ParentContentControl;
                while (repeatAncestor == null && currentCC != null)
                {
                    if (currentCC.Tag.Contains("od:repeat"))
                    {
                        TagData td = new TagData(currentCC.Tag);
                        string variesXPathID = td.getRepeatID();

                        if (variesXPathID.Equals(variesInRepeatId))
                        {
                            return currentCC;
                        }
                    }
                    currentCC = currentCC.ParentContentControl;
                }
            }

            return null;
        }
Esempio n. 18
0
        public WordActiveDocument(IOfficeApplication application, MsWord._Document document)
            : base(application, document.FullName)
        {
            _document = document;

            InitializeWsDocument(FullPath);
        }
Esempio n. 19
0
        public static Wd.Range Find(this Wd.Range range, Wd.WdFieldType type, string value = null)
        {
            var ShowAll = range.Document.ActiveWindow.View.ShowAll;
            var ShowFieldCodes = range.Document.ActiveWindow.View.ShowFieldCodes;

            try
            {
                range.Document.ActiveWindow.View.ShowAll = true;
                range.Document.ActiveWindow.View.ShowFieldCodes = true;
                value = string.Format("^d {0}^w{1}", type.AsGoToString(), value);

                Wd.Range result = range.Duplicate;
                Wd.Find find = result.Find;
                find.ClearFormatting();
                find.Text = value;
                find.Forward = true;
                find.Wrap = Wd.WdFindWrap.wdFindStop;
                find.Forward = true;
                find.MatchCase = false;
                find.MatchWholeWord = false;
                find.MatchWildcards = false;
                find.MatchSoundsLike = false;
                find.MatchAllWordForms = false;
                find.Execute();

                return result;
            }
            finally
            {
                range.Document.ActiveWindow.View.ShowAll = ShowAll;
                range.Document.ActiveWindow.View.ShowFieldCodes = ShowFieldCodes;
            }
        }
        public TEditSidebar(Word.Document WordDoc)
        {
            InitializeComponent();
            AxiomIRISRibbon.Utility.setTheme(this);

            this.tabDebug.Visibility = System.Windows.Visibility.Hidden;
            if (Globals.ThisAddIn.getDebug())
            {
                this.tabDebug.Visibility = System.Windows.Visibility.Visible;
            }

            this.D = Globals.ThisAddIn.getData();
            this.Doc = WordDoc;

            // Initiatlise the tables to hold the XML
            this.DTClauseXML = new DataTable();
            this.DTClauseXML.TableName = "ClauseXML";
            this.DTClauseXML.Columns.Add(new DataColumn("Id", typeof(String)));
            this.DTClauseXML.Columns.Add(new DataColumn("XML", typeof(String)));

            this.CurrentConceptId = "";
            this.CurrentClauseId = "";
            this.CurrentElementId = "";

            this.RefreshConceptList();
            this.GetDropDowns();

            this.ClauseLock = true;
            this.ForceRereshClauseXML = false;
        }
Esempio n. 21
0
 static void RemovePreceedingComma(Wd.Range range)
 {
     range.MoveStart(Wd.WdUnits.wdCharacter, -2);
     if (range.Characters.Count == 2 && range.Text == ", ")
         range.Delete();
     range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd);
 }
Esempio n. 22
0
 static void RemoveTrailingBracket(Wd.Range range)
 {
     range.MoveEnd(Wd.WdUnits.wdCharacter, 2);
     if (range.Characters.Count == 2 && range.Text == "\")")
         range.Delete();
     range.Collapse(Wd.WdCollapseDirection.wdCollapseStart);
 }
 private void WriteDocumentAsXMLFile(Word.Range doc, string pathAndFile)
 {
     System.Xml.XmlWriter xw = null;
     try
     {
         System.Diagnostics.Stopwatch sw = new Stopwatch();
         sw.Start();
         System.IO.FileStream fs = System.IO.File.OpenWrite(pathAndFile);
         fs.SetLength(0);
         xw = System.Xml.XmlWriter.Create(fs
           , new System.Xml.XmlWriterSettings { Indent = true, CloseOutput = true });
         xw.WriteStartDocument();
         xw.WriteStartElement(EL_DOC);
         DomProcessor dp = new DomProcessor(doc, xw);
         dp.Process();
         xw.WriteEndElement();
         xw.WriteEndDocument();
         sw.Stop();
         MessageBox.Show("Elapsed time: " + sw.Elapsed.ToString());
     }
     finally
     {
         if (xw != null)
         {
             xw.Close();
         }
     }
 }
Esempio n. 24
0
 public void CreateDocument()
 {
     try
     {
         Microsoft.Office.Interop.Word.DocumentClass BlankWord = new Microsoft.Office.Interop.Word();
     }
 }
Esempio n. 25
0
File: DocForm.cs Progetto: ruhex/ais
        public static void Form(string Ftext, string Rtext, Word.Document doc)
        {
            var range = doc.Content;

                range.Find.ClearFormatting();
                range.Find.Execute(FindText: Ftext, ReplaceWith: Rtext);
        }
Esempio n. 26
0
        /// <summary>  
        /// 从模板创建新的Word文档,  
        /// </summary>  
        /// <param name="templateName">模板文件名</param>  
        /// <param name="wDoc">返回的Word.Document对象</param>  
        /// <param name="WApp">返回的Word.Application对象</param>  
        /// <returns></returns>  
        public static bool CreateNewWordDocument(string templateName, ref Word.Document wDoc, ref  Word.Application WApp)
        {
            Word.Document thisDocument = null;
            Word.Application thisApplication = new Word.ApplicationClass();
            thisApplication.Visible = false;
            thisApplication.Caption = "";
            thisApplication.Options.CheckSpellingAsYouType = false;
            thisApplication.Options.CheckGrammarAsYouType = false;

            Object Template = templateName;// Optional Object. The name of the template to be used for the new document. If this argument is omitted, the Normal template is used.
            Object NewTemplate = false;// Optional Object. True to open the document as a template. The default value is False.
            Object DocumentType = Word.WdNewDocumentType.wdNewBlankDocument; // Optional Object. Can be one of the following WdNewDocumentType constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. The default constant is wdNewBlankDocument.
            Object Visible = true;//Optional Object. True to open the document in a visible window. If this value is False, Microsoft Word opens the document but sets the Visible property of the document window to False. The default value is True.

            try
            {
                Word.Document wordDoc = thisApplication.Documents.Add(ref Template, ref NewTemplate, ref DocumentType, ref Visible);

                thisDocument = wordDoc;
                wDoc = wordDoc;
                WApp = thisApplication;
                return true;
            }
            catch (Exception ex)
            {
                string err = string.Format("创建Word文档出错,错误原因:{0}", ex.Message);
                throw new Exception(err, ex);
            }
        }
Esempio n. 27
0
        public static bool areOpenDoPEPartsPresent(Word.Document document)
        {
            // TODO consider removing this, or moving it,
            // refer instead Model.cs

            // Modified from OpenDoPE_Wed ThisAddIn
            Office.CustomXMLPart xpathsPart = null;
            Office.CustomXMLPart conditionsPart = null;

            foreach (Office.CustomXMLPart cp in document.CustomXMLParts)
            {
                if (cp.NamespaceURI.Equals(Namespaces.XPATHS))
                {
                    // check for duplicate parts; introduced 2013 12 08
                    if (xpathsPart != null)
                    {
                        MessageBox.Show("Duplicate parts detected. This template needs to be manually repaired.  Please contact your help desk.");
                    }

                    xpathsPart = cp;
                }
                else if (cp.NamespaceURI.Equals(Namespaces.CONDITIONS))
                {
                    conditionsPart = cp;
                }
            }

            return (xpathsPart != null && conditionsPart != null);
        }
Esempio n. 28
0
 public static void OpenNewApplication(Word.Application WordApp, object FileName)
 {
     WordApp.Documents.Open(ref FileName,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);  //新的程序打开原文档
 }
 public void initTaskPane(Word.Document document)
 {
     TaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
     //                new Controls.LogicTaskPaneUserControl(model, Globals.ThisAddIn.Application.ActiveDocument ),
         new Controls.LogicTaskPaneUserControl(model, document),
         "FabDocx Logical Structure");
     TaskPane.Width = 420;
 }
Esempio n. 30
0
 /// <summary>
 /// Prevents strange errors when selection is at the end of a document
 /// </summary>
 public static void InsertBreak_Safe(this Wd.Selection selection, Wd.WdBreakType BreakType = Wd.WdBreakType.wdSectionBreakNextPage)
 {
     var range = selection.Range;
     range.Text = "[Temp]";
     selection.InsertBreak(BreakType);
     range.MoveStart(Wd.WdUnits.wdCharacter, 1);
     range.Delete();
 }
Esempio n. 31
0
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     coverAddin = this;
     word       = new Word();
     word.start();
     DocumentBeforeDoubleClick();
     coverThread = new Thread(new ThreadStart(messageLoop));
     // Start the thread
     coverThread.Start();
 }
Esempio n. 32
0
        private void PictureBox1_Click(object sender, EventArgs e)
        {/*Печать только выделенных записей*/
            try
            {
                Word           _WD = new Word();
                SaveFileDialog sfd = new SaveFileDialog();     //создание компонента SaveFileDialog

                sfd.Filter = "Word Documents (*.docx)|*.docx"; //расширение файла

                sfd.FileName = "Список.docx";                  //имя файла

                if (sfd.ShowDialog() == DialogResult.OK)       //Окно сохранения
                {
                    _WD.MS_Export_Table(dataGridView1, sfd.FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public static Wd.Range Insert(this Wd.BuildingBlock buildingblock, Wd.Range Where, object RichText, Wd.WdLanguageID cultureID)
 {
     Wd.Range range = buildingblock.Insert(Where, RichText);
     range.LanguageID = Wd.WdLanguageID.wdEnglishUS; // Set the default for Asian languages when typing in English
     range.LanguageID = cultureID;
     return range;
 }