private void SetFolderSuffix(XOfficeCommonSettings settings) { Object _false = false; Object _true = true; String defaultSuffixValue = "_files"; Word.Document newDoc = Application.Documents.Add(ref missing, ref missing, ref missing, ref _false); String uniqueName = "XOffice" + DateTime.Now.Ticks.ToString(); Object uniquePath = Path.Combine(settings.PagesRepository, uniqueName); //required by COM interop Object format = Word.WdSaveFormat.wdFormatHTML; newDoc.SaveAs(ref uniquePath, ref format, ref missing, ref missing, ref _false, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); newDoc.Close(ref _false, ref missing, ref missing); DirectoryInfo dirInfo = new DirectoryInfo(settings.PagesRepository); //search for the metadata directory. foreach (DirectoryInfo subDir in dirInfo.GetDirectories()) { if (subDir.Name.StartsWith(uniqueName)) { String suffix = subDir.Name.Replace(uniqueName, ""); settings.MetaDataFolderSuffix = suffix; XOfficeCommonSettingsHandler.WriteRepositorySettings(settings); } } if (settings.MetaDataFolderSuffix == "") { settings.MetaDataFolderSuffix = defaultSuffixValue; } }
/// <summary> /// Default constructor. /// </summary> /// <param name="addinSettingsForm">A reference to an <code>AddinSettingsForm</code> instance.</param> public AddinSettingsFormManager(ref AddinSettingsForm addinSettingsForm) { this.addinSettingsForm = addinSettingsForm; this.addinSettings = new XOfficeCommonSettings(); this.addin = Globals.XWord2003AddIn; this.currentClientType = addin.ClientType; }
/// <summary> /// Makes the login to the server, using the ConnectionSettingsForm /// or the last stored credentials. /// </summary> private void InitializeAddin() { //Set encoding to ISO-8859-1(Western) Application.Options.DefaultTextEncoding = Microsoft.Office.Core.MsoEncoding.msoEncodingWestern; this.SaveFormat = Word.WdSaveFormat.wdFormatHTML; this.AddinStatus.Syntax = this.DefaultSyntax; timer = new System.Timers.Timer(TIMER_INTERVAL); //Repositories and temporary files settings if (XOfficeCommonSettingsHandler.HasSettings()) { XOfficeCommonSettings addinSettings = XOfficeCommonSettingsHandler.GetSettings(); this.DownloadedAttachmentsRepository = addinSettings.DownloadedAttachmentsRepository; this.PagesRepository = addinSettings.PagesRepository; this.clientType = addinSettings.ClientType; } else { this.PagesRepository = Path.GetTempPath(); this.DownloadedAttachmentsRepository = Path.GetTempPath(); this.clientType = XWikiClientType.XML_RPC; } timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); InitializeEventsHandlers(); //Authentication settings if (!AutoLogin()) { ShowConnectToServerUI(); } addinActionsDispatcher = new AddinActionsDispatcher(this); Log.Success("XWord initialized!"); }
/// <summary> /// Makes the login to the server, using the ConnectionSettingsForm /// or the last stored credentials. /// Adds the taskpanes. /// </summary> public void InitializeAddin() { //Set encoding to ISO-8859-1(Western) Application.Options.DefaultTextEncoding = Microsoft.Office.Core.MsoEncoding.msoEncodingWestern; Application.Options.UseNormalStyleForList = true; this.SaveFormat = Word.WdSaveFormat.wdFormatHTML; timer = new System.Timers.Timer(TIMER_INTERVAL); //Repositories and temporary files settings if (XOfficeCommonSettingsHandler.HasSettings()) { addinSettings = XOfficeCommonSettingsHandler.GetSettings(); if (addinSettings.MetaDataFolderSuffix == "") { SetFolderSuffix(addinSettings); } } else { this.AddinSettings = new XOfficeCommonSettings(); } timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); InitializeEventsHandlers(); bool connected = false; bool hasCredentials = LoadCredentials(); if (hasCredentials && AddinSettings.AutoLogin) { Client = XWikiClientFactory.CreateXWikiClient(AddinSettings.ClientType, serverURL, username, password); connected = Client.LoggedIn; } else if (!hasCredentials) { //if the user wants to login at startup, and enter the credentials if (AddinSettings.AutoLogin) { if (ShowConnectToServerUI()) { connected = Client.LoggedIn; this.AddinStatus.Syntax = this.DefaultSyntax; } } } if (!connected) { Globals.Ribbons.XWikiRibbon.SwitchToOfflineMode(); } else if (Client.LoggedIn) { Globals.Ribbons.XWikiRibbon.SwitchToOnlineMode(); } this.AnnotationMaintainer = new AnnotationMaintainer(); addinActions = new AddinActions(this); Log.Success("XWord started"); }
/// <summary> /// Creates a dummy <code>ConverionManeger</code> to be used by unit tests. /// </summary> /// <returns>An instance of a dummy <code>ConversionManager</code></returns> public static ConversionManager DummyConversionManager() { IXWikiClient client = null; client = XWikiClientTestUtil.CreateMockInstance(); XOfficeCommonSettings settings = new XOfficeCommonSettings(); return(new ConversionManager(settings, serverURL, localFolder, docFullName, localFileName, client)); }
/// <summary> /// Creates a new instance of the ConversionManager class. /// </summary> /// <param name="serverURL">The url of the server.</param> /// <param name="localFolder">The local folder where documents are saved/</param> /// <param name="docFullName">The full name of the wiki page.</param> /// <param name="localFileName">The local file coresponding to the edited wiki page.</param> /// <param name="client">IXWikiClient implementation, handling Client server communication.</param> public ConversionManager(XOfficeCommonSettings settings, String serverURL, String localFolder, String docFullName, String localFileName, IXWikiClient client) { states = new BidirectionalConversionStates(serverURL); states.LocalFolder = localFolder; states.PageFullName = docFullName; states.LocalFileName = localFileName; xwikiClient = client; this.settings = settings; localToWebHtml = new LocalToWebHTML(this); webToLocalHtml = new WebToLocalHTML(this); newAttachments = new List <string>(); }
/// <summary> /// Actions to be performed when on form load. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments</param> protected override void ActionFormLoad(object sender, EventArgs e) { addinSettingsForm.LoadingDialogFlag = true; if (addin.ServerURL == "" || addin.ServerURL == null) { addinSettingsForm.GroupBox1Text = "Test server settings"; } else { addinSettingsForm.GroupBox1Text = "Settings"; addinSettingsForm.ServerURL = addin.ServerURL; addinSettingsForm.UserName = addin.Username; addinSettingsForm.Password = addin.Password; } addinSettings = new XOfficeCommonSettings(); addinSettings.PagesRepository = addin.PagesRepository; addinSettings.DownloadedAttachmentsRepository = addin.DownloadedAttachmentsRepository; addinSettings.ClientType = addin.ClientType; addinSettingsForm.TxtPagesRepoText = addin.PagesRepository; addinSettingsForm.TxtAttachmentsRepoText = addin.DownloadedAttachmentsRepository; //init protocol settings addinSettingsForm.ConnectDictionary.Add(addinSettingsForm.ConnectMethods[0], XWikiClientType.XML_RPC); addinSettingsForm.ConnectDictionary.Add(addinSettingsForm.ConnectMethods[1], XWikiClientType.HTTP_Client); addinSettingsForm.ComboProtocolDataSource = addinSettingsForm.ConnectMethods; switch (addin.ClientType) { case XWikiClientType.XML_RPC: addinSettingsForm.ComboProtocolSelectedIndex = 0; break; case XWikiClientType.HTTP_Client: addinSettingsForm.ComboProtocolSelectedIndex = 1; break; } addinSettingsForm.LoadingDialogFlag = false; }