コード例 #1
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);

            if (e.Property.Name != nameof(DocumentTitle) ||
                StateFullDocument is null ||
                _documentTitle == DocumentTitle)
            {
                return;
            }

            _documentTitle = DocumentTitle;

            if (DocumentTitle.Contains(Constants.TempFileExtension))
            {
                return;
            }

            CacheChanges();
            DocumentStyles.Update(Document.Styles);
            StateFullDocument.NewDocument(TemporalFilePath);

            var args = new DocumentUpdatedEventArgs(StateFullDocument.State, ViewDocumentTitle);

            DocumentStateChanged?.Invoke(this, args);
        }
コード例 #2
0
        private ExcelDocument(SpreadsheetDocument doc)
        {
            _doc = doc;
            WorkbookPart wpart = this.GetOSpreadsheet().WorkbookPart;

            _styles        = new DocumentStyles(wpart);
            _sharedStrings = new DocumentSharedStrings(wpart);
            this.Workbook  = new ExcelWorkbook(this);
        }
コード例 #3
0
 /// <summary>
 /// Instances this instance.
 /// </summary>
 /// <returns></returns>
 public static DefaultDocumentStyles Instance(DocumentStyles documentStyles, IDocument document)
 {
     if (_instance == null)
     {
         _instance = new DefaultDocumentStyles();
         _instance._styleDocument = documentStyles;
         _instance._document      = document;
     }
     return(_instance);
 }
コード例 #4
0
 internal ExcelStyle(IStylable stylable, DocumentStyles styles, uint?baseStyleIndex, bool?isHead = false)
 {
     this._stylable  = stylable;
     this._styles    = styles;
     this.StyleIndex = baseStyleIndex;
     if (isHead.HasValue)
     {
         this.SetAlignmentCenter = isHead.Value;
     }
 }
コード例 #5
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            CacheChanges();
            StateFullDocument = new StateFullDocument(TemporalFilePath, this);

            _documentTitle = DocumentTitle;
            DocumentSaved += OnDocumentSaved;

            DocumentStyles.Update(Document.Styles);
        }
コード例 #6
0
 internal ExcelFont(IStylable stylable, DocumentStyles styles, uint?fontId)
 {
     _stylable = stylable;
     _styles   = styles;
     _fontId   = fontId;
     if (_fontId != null)
     {
         FontObject = (Font)_styles.GetFont(_fontId.Value).CloneNode(true);
     }
     else
     {
         FontObject = new Font();
     }
 }
コード例 #7
0
 internal ExcelFont(IStylable stylable, DocumentStyles styles, uint?fontId)
 {
     this._stylable = stylable;
     this._styles   = styles;
     this._fontId   = fontId;
     if (this._fontId.HasValue)
     {
         this.FontObject = (Font)this._styles.GetFont(this._fontId.Value).CloneNode(true);
     }
     else
     {
         this.FontObject = new Font();
     }
 }
コード例 #8
0
 internal ExcelFill(IStylable stylable, DocumentStyles styles, uint?fillId)
 {
     this._stylable = stylable;
     this._styles   = styles;
     this._fillId   = fillId;
     if (this._fillId.HasValue)
     {
         this.FillObject = (Fill)this._styles.GetFill(this._fillId.Value).CloneNode(true);
     }
     else
     {
         this.FillObject = new Fill();
     }
 }
コード例 #9
0
 public ExcelBorder(IStylable stylable, DocumentStyles styles, uint?borderId)
 {
     this._stylable = stylable;
     this._styles   = styles;
     this._borderId = borderId;
     if (this._borderId.HasValue)
     {
         this.BorderObject = (Border)this._styles.GetBorder(this._borderId.Value).CloneNode(true);
     }
     else
     {
         this.BorderObject = new Border();
     }
 }
コード例 #10
0
 internal ExcelFill(IStylable stylable, DocumentStyles styles, uint?fillId)
 {
     _stylable = stylable;
     _styles   = styles;
     _fillId   = fillId;
     if (_fillId != null)
     {
         FillObject = (Fill)_styles.GetFill(_fillId.Value).CloneNode(true);
     }
     else
     {
         FillObject = new Fill();
     }
 }
コード例 #11
0
ファイル: DataOutput.cs プロジェクト: phuongtran7/Yotsuba
        private void AddToBody(List <Run> runList, DocumentStyles formatstyle)
        {
            var new_paragraph = new Paragraph();

            foreach (Run runItem in runList)
            {
                new_paragraph.AppendChild(runItem);
            }

            // Temporary just format DocumentHeading for now
            ApplyStyleToParagraph(formatstyle, new_paragraph);

            DocumentBody.AppendChild(new_paragraph);
        }
コード例 #12
0
 public ExcelBorder(IStylable stylable, DocumentStyles styles, uint?borderId)
 {
     _stylable = stylable;
     _styles   = styles;
     _borderId = borderId;
     if (_borderId != null)
     {
         BorderObject = (Border)_styles.GetBorder(_borderId.Value).CloneNode(true);
     }
     else
     {
         BorderObject = new Border();
     }
 }
コード例 #13
0
ファイル: DataOutput.cs プロジェクト: phuongtran7/Yotsuba
        private void AddToBody(string text, DocumentStyles formatstyle)
        {
            if (!string.IsNullOrEmpty(text))
            {
                var run = CreateRun(text);

                // If the text is a WeekHeading, we should add a line break before it
                if (formatstyle == DocumentStyles.WeekHeading)
                {
                    run.PrependChild(new Break());
                }

                AddToBody(new List <Run> {
                    run
                }, formatstyle);
            }
        }
コード例 #14
0
ファイル: SplitRenderer.cs プロジェクト: lulzzz/CMS-Packages
        private static XElement AddNumeration(XElement body, DocumentStyles documentStyles)
        {
            var levels = body.Elements().Where(documentStyles.IsLevel).ToArray();

            foreach (var level in levels)
            {
                var newLevel = new XElement(Namespaces.Xhtml + "h4",
                                            new XAttribute("level", documentStyles.GetLevel(level)),
                                            //new XText(documentStyles.GetNumeration(level)),
                                            //new XText(" "),
                                            level.Nodes()
                                            );
                newLevel.SetAttributeValue("toc", documentStyles.GetLevelToc(newLevel));
                level.ReplaceWith(newLevel);
            }

            return(body);
        }
コード例 #15
0
ファイル: Entry.cs プロジェクト: lbouriez/GenerateReport
        public static void Generate(EntryParameters parameters)
        {
            try
            {
                DisplayArguments(parameters);

                var model = new FinalDocument(parameters);

                // Create the document
                Documents.CreateDocument(model);

                // Define the styles
                DocumentStyles.DefineStyles(model);

                // Create the cover page
                Cover.DefineCover(model);

                // Create the TOC
                TableOfContents.DefineTableOfContents(model);

                // Merge the files
                External.MergeFiles(model);

                // Generate the document
                GenerateFile(model.Document, parameters);

                Logger.Log($"Process ended correctly.\n" +
                           $"{model.MainTitle.Select(x => x.SubTitle.Count()).Sum()} files were merged.\n" +
                           $"You can find everything inside => {parameters.WorkPath}");
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
            }
            finally
            {
                Logger.Log("Process finished...\n");
            }
        }
コード例 #16
0
 internal ExcelStyle(IStylable stylable, DocumentStyles styles, uint?baseStyleIndex)
 {
     _stylable       = stylable;
     _styles         = styles;
     this.StyleIndex = baseStyleIndex;
 }
コード例 #17
0
ファイル: DataOutput.cs プロジェクト: phuongtran7/Yotsuba
        private void ApplyStyleToParagraph(DocumentStyles style, Paragraph p)
        {
            // If the paragraph has no ParagraphProperties object, create one.
            if (p.Elements <ParagraphProperties>().Count() == 0)
            {
                p.PrependChild <ParagraphProperties>(new ParagraphProperties());
            }

            // Get the paragraph properties element of the paragraph.
            ParagraphProperties pPr = p.Elements <ParagraphProperties>().First();

            switch (style)
            {
            case DocumentStyles.DocumentHeading:
            {
                // Set the style of the paragraph.
                pPr.ParagraphStyleId = new ParagraphStyleId()
                {
                    Val = "DocumentHeading"
                };

                break;
            }

            case DocumentStyles.Author:
            {
                // Set the style of the paragraph.
                pPr.ParagraphStyleId = new ParagraphStyleId()
                {
                    Val = "Author"
                };

                break;
            }

            case DocumentStyles.ProjectHeading:
            {
                pPr.ParagraphStyleId = new ParagraphStyleId()
                {
                    Val = "ProjectHeading"
                };

                break;
            }

            case DocumentStyles.WeekHeading:
            {
                pPr.ParagraphStyleId = new ParagraphStyleId()
                {
                    Val = "WeekHeading"
                };

                break;
            }

            case DocumentStyles.Text:
            {
                pPr.ParagraphStyleId = new ParagraphStyleId()
                {
                    Val = "Text"
                };

                break;
            }

            default: break;
            }
        }
コード例 #18
0
 internal ExcelNumberFormat(IStylable stylable, DocumentStyles styles, uint numFmtId)
 {
     _stylable = stylable;
     _styles   = styles;
     NumFmtId  = numFmtId;
 }
コード例 #19
0
        public Style()
        {
            var docHeader = new Dictionary <string, string>
            {
                { "text-align", "center" }
            };
            var docTitle = new Dictionary <string, string>
            {
                { "text-align", "center" }
            };
            var docAuthor = new Dictionary <string, string>
            {
                { "display", "inline-block" },
                { "margin", "3px" },
                { "font-weight", "bold" }
            };
            var docCreated = new Dictionary <string, string>
            {
                { "display", "inline-block" },
                { "margin", "3px" }
            };

            DocumentStyles.Add(".doc-header", docHeader);
            DocumentStyles.Add(".doc-title", docTitle);
            DocumentStyles.Add(".doc-author", docAuthor);
            DocumentStyles.Add(".doc-created", docCreated);

            var headLink = new Dictionary <string, string>
            {
                { "text-decoration", "none" },
                { "color", "#1812e" }
            };
            var headLinkHover = new Dictionary <string, string>
            {
                { "background-color", "#eac67a" }
            };
            var docHeaderInfo = new Dictionary <string, string>
            {
                { "align-content", "center" },
                { "font-family", "'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif" }
            };
            var headerTitle = new Dictionary <string, string>
            {
                { "font-family", "'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif" }
            };

            HeaderStyles.Add(".header-link", headLink);
            HeaderStyles.Add(".header-link :hover", headLinkHover);
            HeaderStyles.Add(".doc-header-info", docHeaderInfo);
            HeaderStyles.Add(".header-title", headerTitle);

            var nav = new Dictionary <string, string>
            {
                { "height", "100%" },
                { "width", "200px" },
                { "position", "fixed" },
                { "z-index", "1" },
                { "top", "0" },
                { "left", "0" },
                { "background-color", "#18121e" },
                { "overflow-x", "hidden" },
                { "padding-top", "60px" },
                { "transition", "0.5s" }
            };
            var navLink = new Dictionary <string, string>
            {
                { "padding", "8px" },
                { "text-decoration", "none" },
                { "font-size", "25px" },
                { "color", "#eac67a" },
                { "display", "block" },
                { "transition", "0.3s" }
            };
            var navLinkHover = new Dictionary <string, string>
            {
                { "color", "#18121e" },
                { "background-color", "#984b43" }
            };
            var navLinkSubDir = new Dictionary <string, string>
            {
                { "padding", "8px 8px 8px 32px" },
                { "font-size", "20px" },
                { "color", "#eac67a" },
                { "display", "block" },
                { "transition", "0.3s" }
            };

            NavStyles.Add(".sidenav", nav);
            NavStyles.Add(".sidenav a", navLink);
            NavStyles.Add(".sidenav a:hover", navLinkHover);
            NavStyles.Add(".sidenav .nav-sub-dir", navLinkSubDir);

            var body = new Dictionary <string, string>
            {
                { "background-color", "#fff" },
            };
            var contentDiv = new Dictionary <string, string>
            {
                { "font-family", "'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif" },
                { "color", "#233237" },
                { "transition", "margin-left .5s" },
                { "padding-left", "200px" }
            };

            PageStyles.Add("body", body);
            PageStyles.Add("#content-div", contentDiv);
        }
コード例 #20
0
ファイル: ListRenderer.cs プロジェクト: lulzzz/CMS-Packages
        private static IEnumerable <XNode> CreateListItems(IEnumerable <XNode> nodes, DocumentStyles listFormats)
        {
            List <XNode> result = new List <XNode>();

            var node = nodes.FirstOrDefault();

            while (node != null)
            {
                var nextnode = node.NextNode;
                if (node is XElement)
                {
                    if (listFormats.IsListItem(node))
                    {
                        var element = node as XElement;
                        var pair    = listFormats.GetListPair(element);
                        //string numId = element.AttributeValue("numId");
                        //string ilvl = element.AttributeValue("ilvl");
                        var ul = listFormats.GetListElement(pair.NumId, pair.Ilvl);
                        var li = new XElement(Namespaces.Xhtml + "li");
                        li.SetAttributeValue("class", element.AttributeValue("class"));
                        li.AddCleared(node);
                        var count = node.ElementsAfterSelf().Where(e => listFormats.IsListItem(e, pair.NumId, pair.Ilvl)).Count();

                        //TO:Check indent for inner items
                        if (listFormats.IsNumerable(pair.NumId, pair.Ilvl))
                        {
                            for (int i = 0; i < count; i++)
                            {
                                var innerItems = new XElement("InnerItems");
                                node = nextnode;
                                while (node != null)
                                {
                                    nextnode = node.NextNode;
                                    if (listFormats.IsListItem(node, pair.NumId, pair.Ilvl))
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        innerItems.Add(node);
                                    }
                                    node = nextnode;
                                }
                                li.AddCleared(CreateListItems(innerItems.Nodes(), listFormats));
                                ul.Add(li);
                                li = new XElement(Namespaces.Xhtml + "li");
                                if (node is XElement)
                                {
                                    li.SetAttributeValue("class", (node as XElement).AttributeValue("class"));
                                }
                                li.AddCleared(node);
                            }
                        }
                        else
                        {
                            node = nextnode;
                            while (node != null)
                            {
                                nextnode = node.NextNode;
                                if (listFormats.IsListItem(node, pair.NumId, pair.Ilvl))
                                {
                                    ul.Add(li);
                                    li = new XElement(Namespaces.Xhtml + "li");
                                    if (node is XElement)
                                    {
                                        li.SetAttributeValue("class", (node as XElement).AttributeValue("class"));
                                    }
                                    li.AddCleared(node);
                                }
                                else
                                {
                                    nextnode = node;
                                    break;
                                }
                                node = nextnode;
                            }
                        }
                        ul.AddCleared(li);
                        result.Add(ul);
                    }
                    else
                    {
                        var element = CreateListItems((node as XElement), listFormats);
                        result.Add(element);
                    }
                }
                else
                {
                    result.Add(node);
                }
                node = nextnode;
            }
            return(result);
        }
コード例 #21
0
ファイル: ListRenderer.cs プロジェクト: lulzzz/CMS-Packages
 private static XElement CreateListItems(XElement element, DocumentStyles listFormats)
 {
     element.ReplaceNodes(CreateListItems(element.Nodes(), listFormats));
     element.Clear();
     return(element);
 }
コード例 #22
0
ファイル: ListRenderer.cs プロジェクト: lulzzz/CMS-Packages
 public static XDocument RenderLists(XDocument document, DocumentStyles listFormats)
 {
     CreateListItems(document.Root, listFormats);
     return(document);
 }
コード例 #23
0
ファイル: DockPanel.cs プロジェクト: gpanayir/sffwk
 private void OnChangingDocumentStyle(DocumentStyles oldValue) {
 }
コード例 #24
0
ファイル: SplitRenderer.cs プロジェクト: lulzzz/CMS-Packages
        public static XDocument Render(XDocument document, DocumentStyles documentStyles)
        {
            var tocName = HttpContext.Current.Request["Toc"];

            if (tocName == null)
            {
                var pathInfo = GetPathInfo();
                if (pathInfo.StartsWith("/"))
                {
                    pathInfo = pathInfo.Substring(1);
                }
                PathInfoParts = pathInfo.Split('/');
                // get last PathInfo Part
                CurrentTocName = PathInfoParts[PathInfoParts.Length - 1];
            }

            var body = document.Root.Element(Namespaces.Xhtml + "body");

            body = AddNumeration(body, documentStyles);

            var tocs = body.Elements().Where(documentStyles.IsLevel).ToArray();

            var toc = tocs.FirstOrDefault(e => documentStyles.GetLevelToc(e) == CurrentTocName);

            if (toc == null)
            {
                toc            = tocs.FirstOrDefault();
                CurrentTocName = toc?.AttributeValue("toc");
            }


            if (toc != null)
            {
                var tocText = toc.NodesAfterSelf().TakeWhile(node => !documentStyles.IsLevel(node)).ToList();

                tocName = documentStyles.GetLevelToc(toc);


                var innerLinks = tocText.Cast <XElement>().Descendants(Namespaces.Xhtml + "a").Where(a => a.Attribute("href") != null && a.Attribute("href").Value.StartsWith("#")).ToArray();
                foreach (var innerLink in innerLinks)
                {
                    var anchorId = innerLink.AttributeValue("href").Substring(1);
                    var anchor   = body.Descendants(Namespaces.Xhtml + "a")
                                   .FirstOrDefault(a => a.AttributeValue("name") == anchorId);
                    if (anchor != null)
                    {
                        var anchorToc = anchor.Parent.Parent; // need check is valid
                        if (documentStyles.IsLevel(anchorToc))
                        {
                            innerLink.SetAttributeValue("href", GetUrl(anchorToc.AttributeValue("toc")) + innerLink.AttributeValue("href"));
                        }
                        else
                        {
                            anchorToc = anchorToc.NodesBeforeSelf().Reverse().FirstOrDefault(documentStyles.IsLevel) as XElement;
                            if (anchorToc != null)
                            {
                                innerLink.SetAttributeValue("href", GetUrl(anchorToc.AttributeValue("toc")) + innerLink.AttributeValue("href"));
                            }
                        }
                    }
                }


                var prevLink = toc.NodesBeforeSelf().Reverse().FirstOrDefault(documentStyles.IsLevel) as XElement;
                var nextLink = toc.NodesAfterSelf().FirstOrDefault(documentStyles.IsLevel) as XElement;

                var navigation = new XElement(Namespaces.Xhtml + "div",
                                              new XAttribute("class", "Navigation"),
                                              GetLink(prevLink),
                                              GetLink(null),
                                              GetLink(nextLink)
                                              );
                navigation = null;

                body.ReplaceNodes(
                    new XElement(Namespaces.Xhtml + "ul",
                                 new XAttribute("id", "WordDocumentViewerToc"),
                                 tocs.Select(e => new XElement(
                                                 Namespaces.Xhtml + "li",
                                                 documentStyles.GetLevelToc(e) == tocName ? new XAttribute("class", "selected") : null,
                                                 GetLink(e)))
                                 ),
                    navigation,
                    toc, tocText,
                    navigation);
            }

            return(document);
        }