Exemple #1
0
        private void ScriptSectionFormatting()
        {
            var targetScripts =
                DocumentContent.XPathSelectElements(@"//text:script[@script:language = 'Template']", Manager).ToList();

            foreach (var script in targetScripts.Where(script => script.Value.Contains("foreach") || script.Value.Contains("if")))
            {
                CreateControlFlowSection(script);
            }
        }
Exemple #2
0
        private void HandleConditionals()
        {
            var targetComments =
                DocumentContent.XPathSelectElements(@"//text:span", Manager).ToList();

            foreach (
                var comment in
                targetComments.Where(script => script.Value.Contains("foreach") || script.Value.Contains("if")))
            {
                CreateControlFlowFromComment(comment);
            }
        }
Exemple #3
0
        private void ReplaceFields()
        {
            var elements = DocumentContent.XPathSelectElements(@"//text:text-input[ @text:description = 'Template']",
                                                               Manager);
            var nodes = elements.ToList();

            foreach (var element in nodes)
            {
                var attribute         = element.Value;
                var preparedAttribute = attribute.Replace("U+10FFFD", "@");
                var text = new XText(preparedAttribute);
                element.ReplaceWith(text);
            }
        }
Exemple #4
0
        private void ReplaceComments()
        {
            var targetCells = DocumentContent.XPathSelectElements(@"//office:annotation/..", Manager).ToList();

            foreach (var cell in targetCells)
            {
                var comment       = cell.XPathSelectElement(@"./office:annotation/text:p", Manager);
                var preparedValue = comment.Value.Replace("U+10FFFD", "@");
                var parent        = comment.Parent;
                Ensure.That(parent).IsNotNull();
                if (parent != null)
                {
                    parent.Remove();
                }

                XNamespace textNs  = "urn:oasis:names:tc:opendocument:xmlns:text:1.0";
                var        content = new XElement(textNs + "p")
                {
                    Value = preparedValue
                };
                cell.Add(content);
            }
        }