Beispiel #1
0
        private static void ProcessDirectiveTag(XmlDocument xml, XmlElement phe, string value)
        {
            Debug.Assert(xml != null);
            Debug.Assert(phe != null);
            Debug.Assert(!string.IsNullOrEmpty(value));

            var se = new DirectiveElement(xml, value);

            if (phe.ParentNode.ChildNodes.Count == 1)
            {
                phe.ParentNode.ParentNode.ReplaceChild(se, phe.ParentNode);
            }
            else
            {
                phe.ParentNode.ReplaceChild(se, phe);
            }
        }
Beispiel #2
0
        private static void PreprocessElements(OdfContentXmlDocument xml)
        {
            var placeholders = FindAllPlaceholderElements(xml).ToArray();

            foreach (XmlNode placeholder in placeholders)
            {
                string value = ExtractTemplateExpression(placeholder);
                if (value.StartsWith(WellknownConstants.DtlReferenceChar))
                {
                    ProcessIdentifierTag(xml, placeholder, value.Substring(1));
                }
                else if (value.StartsWith(WellknownConstants.DtlDirectiveChar))
                {
                    var directiveNode = new DirectiveElement(xml, value.Substring(1));
                    directiveNode.ReduceTagByCount(placeholder);
                }
                else
                {
                    throw new SyntaxErrorException($"Syntax error: '{value}'");
                }
            }

            var drawFrameElements = xml.SelectNodes("//" + OdfDocument.DrawFrameElement, xml.NamespaceManager);
            var dtlDrawFrames     = new List <XmlNode>();

            foreach (XmlNode node in drawFrameElements)
            {
                var nameAttr = node.Attributes["draw:name"];
                if (nameAttr != null && !string.IsNullOrWhiteSpace(nameAttr.Value) && nameAttr.Value.Trim(' ').StartsWith(WellknownConstants.DtlReferenceChar))
                {
                    dtlDrawFrames.Add(node);
                }
            }

            foreach (var node in dtlDrawFrames)
            {
                ProcessDrawFrameElement(node, xml.NamespaceManager);
            }
        }
Beispiel #3
0
        private void ProcessDirectiveTag(XmlElement placeholderNode, string value)
        {
            var directive = new DirectiveElement(this.TemplateDocument.XmlDocument, value);

            directive.ReduceTagByDirective(placeholderNode);
        }