/// <summary>
        /// Extracts the CSS from StyleSheetExtension objects.
        /// </summary>
        /// <returns></returns>
        private string ExtractCSSFromStyleSheetExtensions()
        {
            SSXManager ssxManager = SSXManager.BuildFromServerPage(manager);

            return(ssxManager.PageCSSContent);
        }
Exemple #2
0
        /// <summary>
        /// Saves the currently edited page or document to the server.
        /// </summary>
        private void SaveToXwiki()
        {
            try
            {
                addin.AnnotationMaintainer.ClearComments();
                String contentFilePath = "";
                addin.ReinforceApplicationOptions();
                String filePath        = addin.ActiveDocumentFullName;
                String currentFileName = Path.GetDirectoryName(addin.ActiveDocumentFullName);
                currentFileName += "\\" + Path.GetFileNameWithoutExtension(addin.ActiveDocumentFullName);
                String tempExportFileName = currentFileName + "_TempExport.html";
                if (!ShadowCopyDocument(addin.ActiveDocumentInstance, tempExportFileName, addin.SaveFormat))
                {
                    ReportSaveProblem();
                    return;
                }
                contentFilePath = tempExportFileName;
                StreamReader sr          = new StreamReader(contentFilePath, Client.ServerEncoding);
                String       fileContent = sr.ReadToEnd();
                sr.Close();
                File.Delete(contentFilePath);
                String cleanHTML = "";

                cleanHTML = new CommentsRemover().Clean(fileContent);
                cleanHTML = new HeadSectionRemover().Clean(cleanHTML);

                ConversionManager pageConverter;
                if (pageConverters.ContainsKey(addin.currentPageFullName))
                {
                    pageConverter = pageConverters[addin.currentPageFullName];
                }
                else
                {
                    pageConverter = new ConversionManager(addin.AddinSettings, addin.serverURL, Path.GetDirectoryName(contentFilePath),
                                                          addin.currentPageFullName, Path.GetFileName(contentFilePath), addin.Client);
                }
                cleanHTML = pageConverter.ConvertFromWordToWeb(cleanHTML);

                SSXManager ssxManager = SSXManager.BuildFromLocalHTML(pageConverter, cleanHTML);

                cleanHTML = new BodyContentExtractor().Clean(cleanHTML);

                //openHTMLDocument(addin.currentLocalFilePath);
                if (addin.AddinStatus.Syntax == null)
                {
                    addin.AddinStatus.Syntax = addin.DefaultSyntax;
                }

                if (SavePage(addin.currentPageFullName, ref cleanHTML, addin.AddinStatus.Syntax))
                {
                    ssxManager.UploadStyleSheetExtensions();
                    pageConverter.UploadAttachments();
                    addin.AnnotationMaintainer.UpdateAnnotations();
                }
            }
            catch (COMException ex)
            {
                string message = "An internal Word error appeared when trying to save your file.";
                message += Environment.NewLine + ex.Message;
                Log.Exception(ex);
                UserNotifier.Error(message);
            }
        }