public void PopulateRemuneration(Enums.Remuneration remuneration, List <DocumentFragment> documents)
        {
            DocumentFragment frag = documents.Find(i => i.Title.Equals(remuneration.ToString(), StringComparison.OrdinalIgnoreCase));

            Document.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.Remuneration, remuneration.ToString());

            if (!Document.HasBookmark(Constants.WordBookmarks.AddRenumeration))
            {
                return;
            }

            if (Document.HasBookmark(Constants.WordBookmarks.Renumeration))
            {
                if (Document.MoveCursorToStartOfBookmark(Constants.WordBookmarks.Renumeration))
                {
                    Document.DeletePage();
                    Document.AddBookmarkToCurrentLocation(Constants.WordBookmarks.AddRenumeration);
                }
            }
            if (String.IsNullOrEmpty(frag.Url))
            {
                return;
            }

            if (!Document.MoveCursorToStartOfBookmark(Constants.WordBookmarks.AddRenumeration))
            {
                return;
            }

            Document.MoveCursorUp(1);
            Document.InsertPageBreak();
            Document.ChangePageOrientToPortrait();
            Document.InsertFile(frag.Url);
        }
Exemple #2
0
  DOMDocumentFragment createWrapper(DocumentFragment node)
  {
    DOMDocumentFragment wrapper = new DOMDocumentFragment(this, node);
    _wrapperMap.put(node, wrapper);

    return wrapper;
  }
Exemple #3
0
        /// <summary>Called when the kids are all ready.</summary>
        public override void OnChildrenLoaded()
        {
            // Create frag:
            content           = new DocumentFragment();
            content.document_ = document_;

            // Transfer kids into content:
            content.childNodes_ = childNodes_;

            if (childNodes_ == null)
            {
                return;
            }

            for (int i = childNodes_.length - 1; i >= 0; i--)
            {
                // Get the node:
                Node node = childNodes_[i];

                // Simple parent change:
                node.parentNode_ = content;
            }

            childNodes_ = null;
        }
 public HTMLTemplateElement()
     : base(Tags.Template, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTableScoped | NodeFlags.HtmlTableSectionScoped)
 {
     _content = new DocumentFragment {
         Owner = Owner
     };
 }
        public IDocumentFragment createDocumentFragment(IPluglet root, XmlNodeList nodes)
        {
            DocumentFragment docFrag = new DocumentFragment();
            IPluglet         result  = extractPluglet(root, nodes[0], this.plug);

            docFrag.Pluglet = result;
            docFrag.Parent  = null;
            createDocumentFragment(root, nodes[0], docFrag);
            return(docFrag);
        }
        private void CreateFragments()
        {
            RadDocument radDocument = this.radRichTextBox.Document;

            #region radrichtextbox-features-formatting-api_6
            DocumentFragment fragmentFromDocument = new DocumentFragment(radDocument);
            #endregion

            #region radrichtextbox-features-formatting-api_8
            DocumentFragment fragmentFromSelection = radDocument.Selection.CopySelectedDocumentElements();
            #endregion
        }
 internal HtmlTemplateElement(Document nodeDocument, string prefix = null)
     : base(Name, nodeDocument, prefix)
 {
     if (!GetIsTemplateDocument(nodeDocument))
     {
         var templateDocument = (Document)nodeDocument.CloneNode();
         SetIsTemplateDocument(templateDocument, true);
         SetTemplateDocument(nodeDocument, templateDocument);
         nodeDocument = templateDocument;
     }
     Content = new DocumentFragment(nodeDocument);
 }
Exemple #8
0
        /// <summary>
        /// Runs the mutation macro as defined in 5.2.2 Mutation methods
        /// of http://www.w3.org/TR/domcore/.
        /// </summary>
        /// <param name="nodes">The nodes array to add.</param>
        /// <returns>A (single) node.</returns>
        public static INode MutationMacro(this INode[] nodes)
        {
            if (nodes.Length > 1)
            {
                var node = new DocumentFragment();

                for (int i = 0; i < nodes.Length; i++)
                {
                    node.AppendChild(nodes[i]);
                }

                return(node);
            }

            return(nodes[0]);
        }
Exemple #9
0
        /// <summary>
        /// Find corrosponding Pluglet for given segmentname and create new segment
        /// </summary>
        /// <param name="segmentName"></param>
        /// <param name="segmentDetails"></param>
        private void CreateAndAddNewSegment(string segmentName, string[] segmentDetails)
        {
            string   errors = string.Empty;
            IPluglet nextPluglet;

            string location = "EDIReader.CreateAndAddNewSegment";

            Logger.Debug(location, "Adding {0} segment", segmentName);

            nextPluglet = CheckForMissingSegments(segmentName);

            if (nextPluglet == null)
            {
                //TODO: Revisit following if condition - do we really want to ignore ISA/GS segment missing in schema?
                if (segmentName != "ISA" && segmentName != "GS")
                {
                    errors = string.Format("{0} segment not found in schema after {1}", segmentName, CurrentPluglet.Name);

                    Logger.Error(location, "{0} - {1}", GetCurrentPosContext(), errors);
                }
            }
            else
            {
                DocumentFragment newFragment = nextPluglet.ConstructDocumentFragment(segmentDetails, false, EDIDelimiters, out errors);

                if (newFragment == null)
                {
                    errors = string.Format("{0} DocumentFragment creation failed. Errors: {1}", segmentName, errors);
                    Logger.Error(location, "{0} - {1}", GetCurrentPosContext(), errors);
                }
                else
                {
                    ((DocumentFragment)FatpipeDocumentInst.RootFragment).AddDocumentFragment(newFragment);

                    CurrentPluglet = newFragment.Pluglet;
                }
            }

            if (!string.IsNullOrEmpty(errors))
            {
                if (FatpipeDocumentInst.Errors == null)
                {
                    FatpipeDocumentInst.Errors = new List <string>();
                }
                FatpipeDocumentInst.Errors.Add(errors);
            }
        }
        public override IOperationResult <T> GetResultWithValue()
        {
            var result = new DocumentFragment <T>(Builder);

            try
            {
                var status = GetResponseStatus();
                result.Success   = GetSuccess();
                result.Message   = GetMessage();
                result.Status    = GetParentStatus(status);
                result.Cas       = Header.Cas;
                result.Exception = Exception;

                CurrentSpec.Value  = GetValue();
                CurrentSpec.Status = status;
                result.Value       = new List <OperationSpec> {
                    CurrentSpec
                };

                // Read MutationToken after GetValue(), which may fill it with a value
                result.Token = MutationToken ?? DefaultMutationToken;

                //clean up and set to null
                if (!result.IsNmv())
                {
                    Data.Dispose();
                    Data = null;
                }
            }
            catch (Exception e)
            {
                result.Exception = e;
                result.Success   = false;
                result.Status    = ResponseStatus.ClientFailure;
            }
            finally
            {
                if (Data != null && !result.IsNmv())
                {
                    Data.Dispose();
                }
            }

            return(result);
        }
        public void When_Bytes_Are_Null_Return_Default()
        {
            var typeSerializer = new Mock <ITypeSerializerProvider>();
            var fragment       = new DocumentFragment <dynamic>(typeSerializer.Object)
            {
                Value = new List <OperationSpec>
                {
                    new OperationSpec
                    {
                        Bytes  = null, //ack!
                        OpCode = OperationCode.Get
                    }
                }
            };

            Assert.DoesNotThrow(() => fragment.Content <dynamic>(0));
            Assert.AreEqual(default(dynamic), fragment.Content <dynamic>(0));
            Assert.IsNull(fragment.Content <Poco>(0));
        }
        private void InsertFragmentFromDocument(RadDocument document)
        {
            if (document != null)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    this.radRichTextBox.InsertSectionBreak(SectionBreakType.NextPage);
                }

                document.Selection.SelectAll();
                DocumentFragment frag = new DocumentFragment(document.Selection);
                radRichTextBox.InsertFragment(frag);

                CopySectionProperties(document, radRichTextBox.Document);
            }
        }
Exemple #13
0
        private void InsertFragmentFromDocument(RadDocument document)
        {
            if (document != null)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    this.radRichTextBox.InsertSectionBreak(SectionBreakType.NextPage);
                }

                document.Selection.SelectAll();
                DocumentFragment frag = new DocumentFragment(document.Selection);
                radRichTextBox.InsertFragment(frag);

                CopySectionProperties(document, radRichTextBox.Document);
            }
        }
        protected override DocumentFragment GetResultFragment()
        {
            int totalPageCount              = 1;
            int totalPageInCurrentSection   = 1;
            int currentPageInCurrentSection = 1;

            if (this.EvaluationContext != null)
            {
                totalPageCount = this.GetTotalPageCount();

                LayoutBox box = this.EvaluationContext.AssociatedLayoutBoxInMainDocument ?? this.FieldStart.FirstLayoutBox;

                currentPageInCurrentSection = this.GetCurrentPageFromSectionPages(box);
                totalPageInCurrentSection   = this.GetPageCountInSection(box);
            }

            return(DocumentFragment.CreateFromInline(new Span(
                                                         string.Format("Total pages in the document: {0}. Pages in current section: {1} / {2}",
                                                                       totalPageCount, currentPageInCurrentSection, totalPageInCurrentSection))));
        }
Exemple #15
0
        protected override DocumentFragment GetResultFragment()
        {
            int totalPagesCount             = 1;
            int totalPagesInCurrentSection  = 1;
            int currentPageInCurrentSection = 1;

            if (this.EvaluationContext != null)
            {
                totalPagesCount = this.GetTotalPageCount();

                LayoutBox box = this.EvaluationContext.AssociatedLayoutBoxInMainDocument ?? this.FieldStart.FirstLayoutBox;
                currentPageInCurrentSection = this.GetCurrentPageFromSectionPages(box);
                totalPagesInCurrentSection  = this.GetPageCountInSection(box);
            }

            string totalPagesCountWithFormatting             = this.GetNumberWithFormatting(totalPagesCount);
            string totalPagesInCurrentSectionWithFormatting  = this.GetNumberWithFormatting(currentPageInCurrentSection);
            string currentPageInCurrentSectionWithFormatting = this.GetNumberWithFormatting(totalPagesInCurrentSection);

            string textToInsert = !string.IsNullOrEmpty(this.DocumentName)
                ? string.Format("Total pages in the document ({0}): {1}. Pages in current section: {2} / {3}",
                                this.DocumentName,
                                totalPagesCountWithFormatting,
                                totalPagesInCurrentSectionWithFormatting,
                                currentPageInCurrentSectionWithFormatting)
                : string.Format("Total pages in the document: {0}. Pages in current section: {1} / {2}",
                                totalPagesCountWithFormatting,
                                totalPagesInCurrentSectionWithFormatting,
                                currentPageInCurrentSectionWithFormatting);

            Span spanToInsert = new Span(textToInsert);

            Span currentSpan = this.EvaluationContext.Document.CaretPosition.GetCurrentSpan();

            if (currentSpan != null)
            {
                spanToInsert.CopyPropertiesFrom(currentSpan);
            }

            return(DocumentFragment.CreateFromInline(spanToInsert));
        }
        public void When_Bytes_Are_Empty_For_Poco_Return_Default()
        {
            var typeSerializer = new Mock <ITypeSerializerProvider>();

            typeSerializer.Setup(x => x.Serializer).Returns(new DefaultSerializer());

            var fragment = new DocumentFragment <dynamic>(typeSerializer.Object)
            {
                Value = new List <OperationSpec>
                {
                    new OperationSpec
                    {
                        Bytes  = new byte[] {}, //doh!
                        OpCode = OperationCode.Get
                    }
                }
            };

            Assert.DoesNotThrow(() => fragment.Content <Poco>(0));
            Assert.AreEqual(default(Poco), fragment.Content <Poco>(0));
            Assert.IsNull(fragment.Content <Poco>(0));
        }
Exemple #17
0
        public void PasteNewText()
        {
            DocumentFragment clipboardDocument     = null;
            string           clipboardText         = null;
            bool             clipboardContainsData = false;

            if (ClipboardEx.ContainsDocument(null))
            {
                clipboardDocument     = ClipboardEx.GetDocument();
                clipboardContainsData = true;
            }
            else if (ClipboardEx.ContainsText(null))
            {
                clipboardText         = ClipboardEx.GetText(null);
                clipboardContainsData = true;
            }

            if (!clipboardContainsData)
            {
                return;
            }

            this.radRichTextEditor1.ChangeFontFamily(new Telerik.WinControls.RichTextEditor.UI.FontFamily("Consolas"));

            if (clipboardDocument != null)
            {
                RadDocument       doc    = new RadDocument();
                RadDocumentEditor editor = new RadDocumentEditor(doc);
                editor.InsertFragment(clipboardDocument);

                string text = provider.Export(doc);

                this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.Insert(text);
            }
            else if (!string.IsNullOrEmpty(clipboardText))
            {
                this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.Insert(clipboardText);
            }
        }
        public void createDocumentFragment(IPluglet root, XmlNode node, DocumentFragment docFrag)
        {
            foreach (XmlNode temp in node.ChildNodes)
            {
                if (!temp.HasChildNodes)
                {
                    continue;
                }
                IPluglet         result  = extractPluglet(root, temp, this.plug);
                DocumentFragment current = new DocumentFragment();
                current.Pluglet = result;
                current.Parent  = docFrag;

                if (!temp.FirstChild.HasChildNodes)
                {
                    current.Value = temp.FirstChild.Value;
                }

                DocumentFragmentExtensions.AddDocumentFragment(docFrag, current);
                createDocumentFragment(root, temp, docFrag);
            }
        }
Exemple #19
0
        private void InsertFragmentFromDocument(RadDocument document)
        {
            if (document != null)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    radRichTextBox.Document.InsertSectionBreak(radRichTextBox.Document.CaretPosition,
                                                               radRichTextBox.Document.CaretPosition.GetCurrentInline().ExtractStyleFromLocalProperties(), SectionBreakType.NextPage);
                }

                document.Selection.SelectAll();
                DocumentFragment frag = document.Selection.CopySelectedDocumentElements();
                document.Selection.Clear();
                radRichTextBox.Document.InsertFragment(frag);

                CopySectionProperties(document, radRichTextBox.Document);
            }
        }
Exemple #20
0
        public override IOperationResult <T> GetResultWithValue()
        {
            var result = new DocumentFragment <T>(_builder);

            try
            {
                result.Success   = GetSuccess();
                result.Message   = GetMessage();
                result.Status    = GetResponseStatus();
                result.Cas       = Header.Cas;
                result.Exception = Exception;
                result.Token     = MutationToken ?? DefaultMutationToken;
                result.Value     = GetCommandValues();

                //clean up and set to null
                if (!result.IsNmv())
                {
                    Data.Dispose();
                    Data = null;
                }
            }
            catch (Exception e)
            {
                result.Exception = e;
                result.Success   = false;
                result.Status    = ResponseStatus.ClientFailure;
            }
            finally
            {
                if (Data != null && !result.IsNmv())
                {
                    Data.Dispose();
                }
            }

            return(result);
        }
Exemple #21
0
        public Fragment(params Union <string, Widget, HTMLElement>[] typos)
        {
            Content = Document.CreateDocumentFragment();

            Widget.AppendTypos(Content, typos);
        }
        /// <summary>
        /// Sets the child fragment for when each navigation item is selected
        /// </summary>
        private void SetFrameFragment(int index)
        {
            assignment = assignmentViewModel.SelectedAssignment;
            //var transaction = FragmentManager.BeginTransaction ();
            var screen = Constants.Navigation [index];

            switch (screen)
            {
            case "Summary": {
                var fragment = new SummaryFragment();
                fragment.Assignment = assignment;
//                        transaction.SetTransition (FragmentTransit.FragmentOpen);
//                        transaction.Replace (Resource.Id.contentFrame, fragment);
//                        transaction.Commit ();
                items.Visibility        =
                    addItems.Visibility = ViewStates.Invisible;
                addExpense.Visibility   =
                    addLabor.Visibility = ViewStates.Gone;
            }
            break;

            case "Map": {
                var fragment = new MapFragment();
//                        transaction.SetTransition (FragmentTransit.FragmentOpen);
//                        transaction.Replace (Resource.Id.contentFrame, fragment);
//                        transaction.Commit ();
                items.Visibility        =
                    addItems.Visibility = ViewStates.Invisible;
                addExpense.Visibility   =
                    addLabor.Visibility = ViewStates.Gone;
            }
            break;

            case "Items": {
                var fragment = new ItemFragment();
                fragment.Assignment = assignment;
                itemViewModel.LoadAssignmentItemsAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.AssignmentItems = itemViewModel.AssignmentItems;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            items.Visibility        =
                                addItems.Visibility = ViewStates.Visible;
                            addExpense.Visibility   =
                                addLabor.Visibility = ViewStates.Gone;
                            items.Text = string.Format("({0}) Items", assignment.TotalItems.ToString());
                        });
                    });
            }
            break;

            case "Labor Hours": {
                var fragment = new LaborHourFragment();
                laborViewModel.LoadLaborHoursAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.LaborHours = laborViewModel.LaborHours;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            addLabor.Visibility     =
                                items.Visibility    = ViewStates.Visible;
                            addExpense.Visibility   =
                                addItems.Visibility = ViewStates.Gone;
                            items.Text = string.Format("{0} hrs", assignment.TotalHours.TotalHours.ToString("0.0"));
                        });
                    });
            }
            break;

            case "Confirmations": {
                var fragment = new ConfirmationFragment();
                photoViewModel.LoadPhotosAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.Photos     = photoViewModel.Photos;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            addLabor.Visibility     =
                                items.Visibility    = ViewStates.Invisible;
                            addExpense.Visibility   =
                                addItems.Visibility = ViewStates.Gone;
                        });
                    });
            }
            break;

            case "Expenses": {
                var fragment = new ExpenseFragment();
                expenseViewModel.LoadExpensesAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.Expenses   = expenseViewModel.Expenses;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            addLabor.Visibility       =
                                addItems.Visibility   = ViewStates.Gone;
                            items.Visibility          =
                                addExpense.Visibility = ViewStates.Visible;
                            items.Text = assignment.TotalExpenses.ToString("$0.00");
                        });
                    });
            }
            break;

            case "Documents": {
                var fragment = new DocumentFragment();
                documentViewModel.LoadDocumentsAsync().ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.Documents = documentViewModel.Documents;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            items.Visibility        =
                                addItems.Visibility = ViewStates.Invisible;
                            addExpense.Visibility   =
                                addLabor.Visibility = ViewStates.Gone;
                        });
                    });
            }
            break;

            case "History": {
                var fragment = new HistoryFragment();
                historyViewModel.LoadHistoryAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.History    = historyViewModel.History;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            items.Visibility        =
                                addItems.Visibility = ViewStates.Invisible;
                            addExpense.Visibility   =
                                addLabor.Visibility = ViewStates.Gone;
                        });
                    });
            }
            break;

            default:
                break;
            }
        }
Exemple #23
0
        public IDocumentFragment CopyContent()
        {
            var fragment = new DocumentFragment {
                Owner = _start.Node.Owner as Document
            };

            if (_start.Equals(_end))
            {
                return(fragment);
            }

            var originalStart = _start;
            var originalEnd   = _end;

            if (originalStart.Node == originalEnd.Node && _start.Node is ICharacterData)
            {
                var text  = (ICharacterData)originalStart.Node;
                var strt  = originalStart.Offset;
                var span  = originalEnd.Offset - originalStart.Offset;
                var clone = (ICharacterData)text.Clone();
                clone.Data = text.Substring(strt, span);
                fragment.AppendChild(clone);
                return(fragment);
            }

            var commonAncestor = originalStart.Node;

            while (!commonAncestor.IsInclusiveAncestorOf(originalEnd.Node))
            {
                commonAncestor = commonAncestor.Parent;
            }

            var firstPartiallyContainedChild = !originalStart.Node.IsInclusiveAncestorOf(originalEnd.Node) ?
                                               commonAncestor.GetElements <INode>(predicate: IsPartiallyContained).FirstOrDefault() : null;
            var lastPartiallyContainedchild = !originalEnd.Node.IsInclusiveAncestorOf(originalStart.Node) ?
                                              commonAncestor.GetElements <INode>(predicate: IsPartiallyContained).LastOrDefault() : null;
            var containedChildren = commonAncestor.GetElements <INode>(predicate: Intersects).ToList();

            if (containedChildren.OfType <IDocumentType>().Any())
            {
                throw new DomException(ErrorCode.HierarchyRequest);
            }

            if (firstPartiallyContainedChild is ICharacterData)
            {
                var text  = (ICharacterData)originalStart.Node;
                var strt  = originalStart.Offset;
                var span  = text.Length - originalStart.Offset;
                var clone = (ICharacterData)text.Clone();
                clone.Data = text.Substring(strt, span);
                fragment.AppendChild(clone);
            }
            else if (firstPartiallyContainedChild != null)
            {
                var clone = firstPartiallyContainedChild.Clone();
                fragment.AppendChild(clone);
                var subrange = new Range(originalStart, new Boundary {
                    Node = firstPartiallyContainedChild, Offset = firstPartiallyContainedChild.ChildNodes.Length
                });
                var subfragment = subrange.CopyContent();
                fragment.AppendChild(subfragment);
            }

            foreach (var child in containedChildren)
            {
                fragment.AppendChild(child.Clone());
            }

            if (lastPartiallyContainedchild is ICharacterData)
            {
                var text  = (ICharacterData)originalEnd.Node;
                var clone = (ICharacterData)text.Clone();
                clone.Data = text.Substring(0, originalEnd.Offset);
                fragment.AppendChild(clone);
            }
            else if (lastPartiallyContainedchild != null)
            {
                var clone = lastPartiallyContainedchild.Clone();
                fragment.AppendChild(clone);
                var subrange = new Range(new Boundary {
                    Node = lastPartiallyContainedchild, Offset = 0
                }, originalEnd);
                var subfragment = subrange.CopyContent();
                fragment.AppendChild(subfragment);
            }

            return(fragment);
        }
 protected override DocumentFragment GetResultFragment()
 {
     return(DocumentFragment.CreateFromInline(new Span(this.MyProperty)));
 }
        private void ReplaceSemanticRange(RadDocument document, string semanticRangeName, DocumentFragment replacement)
        {
            RecipeRangeStart start = null;
            RecipeRangeEnd end = null;
            foreach (RecipeRangeStart rangeStart in document.GetAnnotationMarkersOfType<RecipeRangeStart>())
            {
                if (rangeStart.Name == semanticRangeName)
                {
                    start = rangeStart;
                    end = (RecipeRangeEnd)rangeStart.End;
                }
            }

            if (start != null && end != null)
            {
                DocumentPosition startPosition = new DocumentPosition(document);
                startPosition.MoveToInline((InlineLayoutBox)start.FirstLayoutBox, 0);
                startPosition.MoveToNext();
                DocumentPosition endPosition = new DocumentPosition(document);
                endPosition.MoveToInline((InlineLayoutBox)end.FirstLayoutBox, 0);

                document.DeleteRange(startPosition, endPosition);

                document.CaretPosition.MoveToInline((InlineLayoutBox)start.FirstLayoutBox, 0);
                document.CaretPosition.MoveToNext();
                document.InsertFragment(replacement);
            }
        }
        private string ExportAnnotationRangeFragment(RadDocument document, string semanticRangeName)
        {
            RecipeRangeStart semanticRangestart = null;
            RecipeRangeEnd semanticRangeEnd = null;
            foreach (RecipeRangeStart rangeStart in document.GetAnnotationMarkersOfType<RecipeRangeStart>())
            {
                if (rangeStart.Name == semanticRangeName)
                {
                    semanticRangestart = rangeStart;
                    semanticRangeEnd = (RecipeRangeEnd)rangeStart.End;
                }
            }

            if (semanticRangestart != null && semanticRangeEnd != null)
            {
                DocumentPosition startPosition = new DocumentPosition(document);
                startPosition.MoveToInline((InlineLayoutBox)semanticRangestart.FirstLayoutBox, 0);

                DocumentPosition endPosition = new DocumentPosition(document);
                endPosition.MoveToInline((InlineLayoutBox)semanticRangeEnd.FirstLayoutBox, 0);

                DocumentSelection selection = new DocumentSelection(document);
                selection.SetSelectionStart(startPosition);
                selection.AddSelectionEnd(endPosition);

                DocumentFragment fragment = new DocumentFragment(selection);
                RadDocument fragmentDocument = fragment.ToDocument();

                HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider();
                htmlFormatProvider.ExportSettings = new HtmlExportSettings();
                htmlFormatProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
                htmlFormatProvider.ExportSettings.StylesExportMode = StylesExportMode.Inline;
                htmlFormatProvider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles;

                return htmlFormatProvider.Export(fragmentDocument);
            }

            return string.Empty;
        }
 public HtmlTemplateElement(Document owner, String prefix = null)
     : base(owner, TagNames.Template, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTableScoped | NodeFlags.HtmlTableSectionScoped)
 {
     _content = new DocumentFragment(owner);
 }
Exemple #28
0
        /// <summary>
        /// Find corrosponding Pluglet for given segmentname and create new segment
        /// </summary>
        /// <param name="segmentName"></param>
        /// <param name="segmentDetails"></param>
        private void CreateAndAddNewSegment(string segmentName, string[] segmentDetails)
        {
            const string firstSegmentName = "ST";

            string   errorMsgs = string.Empty;
            IPluglet nextPluglet;

            string location = "EDIReader.CreateAndAddNewSegment";

            Logger.Debug(location, "Adding {0} segment", segmentName);

            string missingMandatorySegments;

            nextPluglet = CurrentPluglet.GetSegmentPluglet(segmentName, segmentDetails, firstSegmentName, out missingMandatorySegments);

            // First add missing mandatory segment errors
            if (nextPluglet != null && !string.IsNullOrWhiteSpace(missingMandatorySegments))
            {
                string error = string.Format("Missing mandatory segments ({0}) between {1} and {2}"
                                             , missingMandatorySegments, CurrentPluglet.Tag, segmentName);

                if (FatpipeDocumentInst.Errors == null)
                {
                    FatpipeDocumentInst.Errors = new List <string>();
                }
                FatpipeDocumentInst.Errors.Add(error);

                Logger.Error("EDIReader.CreateAndAddNewSegment", EventId.EDIReaderMissingMandatorySegment, "{0} - {1}", GetCurrentPosContext(), error);

                EdiErrorType errorType = nextPluglet.IsIgnore ? EdiErrorType.Warning : EdiErrorType.Error;

                foreach (string segment in missingMandatorySegments.Split(','))
                {
                    Errors.AddSegmentError(segmentName, X12ErrorCode.MandatorySegmentMissingCode
                                           , string.Format("{0} : {1}", X12ErrorCode.GetStandardSegmentErrorDescription(X12ErrorCode.MandatorySegmentMissingCode), segment)
                                           , SegmentNumber, this.CurrentSegmentStartPos, this.CurrentSegmentEndPos - 1, errorType);
                }
            }

            if (nextPluglet == null)
            {
                /* //TODO: Revisit following if condition - do we really want to ignore ISA/GS segment missing in schema?
                 * if (segmentName != "ISA" && segmentName != "GS")
                 * {
                 *   errors = string.Format("{0} segment not found in schema after {1}", segmentName, CurrentPluglet.Name);
                 *
                 *   Logger.Error(location, EventId.EDIReaderUnknownSegment, "{0} - {1}", GetCurrentPosContext(), errors);
                 *   Errors.AddSegmentError(segmentName, X12ErrorCode.UnrecognizedSegmentIDCode
                 *       , X12ErrorCode.GetStandardSegmentErrorDescription(X12ErrorCode.UnrecognizedSegmentIDCode), SegmentNumber);
                 * }
                 */
                //experimenting with unknown here above is actual
                //IPluglet unknown = new Pluglet("UNRECOGNIZED_SEGMENT", "Unknown Segment", PlugletType.Segment, CurrentPluglet.Parent);
                IPluglet unknown = new Pluglet(
                    new PlugletInput()
                {
                    Name            = "UNRECOGNIZED_SEGMENT",
                    Definition      = "Unknown Segment",
                    Type            = PlugletType.Segment,
                    Parent          = CurrentPluglet.Parent,
                    IsIgnore        = false,
                    AddToParent     = false,
                    IsTagSameAsName = true,
                });

                //  IPluglet x = new Pluglet("child"+i, "Unknown Data", PlugletType.Data, unknown);
                //unknown.Children.Add(x);
                //}

                //DocumentFragment newFragment = unknown.ConstructDocumentFragment(segmentDetails, false, EDIDelimiters, out errors);

                errorMsgs = string.Format("{0} segment not found in schema after {1}", segmentName, CurrentPluglet.Name);

                Errors.AddSegmentError(segmentName, X12ErrorCode.UnrecognizedSegmentIDCode
                                       , X12ErrorCode.GetStandardSegmentErrorDescription(X12ErrorCode.UnrecognizedSegmentIDCode), SegmentNumber
                                       , this.CurrentSegmentStartPos, this.CurrentSegmentEndPos - 1, EdiErrorType.Error);

                DocumentFragment newFragment = new DocumentFragment()
                {
                    Pluglet  = unknown,
                    Children = new List <IDocumentFragment>(),
                };

                IPluglet         childPluglet = new Pluglet("Data", "Data", PlugletType.Data, null);
                DocumentFragment child        = new DocumentFragment()
                {
                    Parent         = newFragment,
                    Pluglet        = childPluglet,
                    Children       = null,
                    SequenceNumber = SegmentNumber,
                    StartOffset    = this.CurrentSegmentStartPos,
                    EndOffset      = this.CurrentSegmentEndPos - 1,
                };

                newFragment.Children.Add(child);
                child.Value = CurrentSegment;

                if (newFragment == null)
                {
                    errorMsgs = string.Format("{0} DocumentFragment creation failed. Errors: {1}", segmentName, errorMsgs);
                    Logger.Error(location, EventId.EDIReaderDocFragmentCreation, "{0} - {1}", GetCurrentPosContext(), errorMsgs);
                    //TODO: what should be the code here?
                    //Errors.AddGenericError(segmentName, X12ErrorCode.???
                }
                else
                {
                    ((DocumentFragment)FatpipeDocumentInst.RootFragment).AddDocumentFragment(newFragment);

                    // CurrentPluglet = newFragment.Pluglet;
                }

                //experimenting with unknown here
            }
            else
            {
                if (nextPluglet.RepetitionInfo.MaxOccurs == 0)
                {
                    Errors.AddSegmentError(segmentName, X12ErrorCode.UnexpectedSegmentCode
                                           , string.Format("{0} : {1}", X12ErrorCode.GetStandardSegmentErrorDescription(X12ErrorCode.UnexpectedSegmentCode), nextPluglet.Tag)
                                           , SegmentNumber, this.CurrentSegmentStartPos, this.CurrentSegmentEndPos - 1, EdiErrorType.Error);
                }
                else
                {
                    DocumentFragment newFragment = nextPluglet.ConstructDocumentFragment(segmentDetails, false, EDIDelimiters, SegmentNumber,
                                                                                         this.CurrentSegmentStartPos, this.CurrentSegmentEndPos - 1, ref errors, out errorMsgs);

                    if (newFragment == null)
                    {
                        //errorMsgs = string.Format("{0} DocumentFragment creation failed. Errors: {1}", segmentName, errorMsgs);
                        Logger.Error(location, EventId.EDIReaderDocFragmentCreation, "{0} - {1}", GetCurrentPosContext(), errorMsgs);
                        // TODO: Replace UnexpectedSegmentCode with appropriate one
                        Errors.AddGenericError(segmentName, X12ErrorCode.UnexpectedSegmentCode, errorMsgs, SegmentNumber, this.CurrentSegmentStartPos, this.CurrentSegmentEndPos);
                    }
                    else
                    {
                        ((DocumentFragment)FatpipeDocumentInst.RootFragment).AddDocumentFragment(newFragment);

                        CurrentPluglet = newFragment.Pluglet;
                    }
                }
            }

            if (!string.IsNullOrEmpty(errorMsgs))
            {
                if (FatpipeDocumentInst.Errors == null)
                {
                    FatpipeDocumentInst.Errors = new List <string>();
                }
                FatpipeDocumentInst.Errors.Add(errorMsgs);
            }
        }
Exemple #29
0
 public HTMLTemplateElement(Document document, DocumentFragment content, string localName) : base(document, localName)
 {
     this.content = content;
 }
 private void InsertFragment(DocumentFragment fragment)
 {
     #region radrichtextbox-features-formatting-api_5
     this.radRichTextBox.InsertFragment(fragment);
     #endregion
 }
Exemple #31
0
 public DocumentFragment CreateDocumentFragment()
 {
     return(DocumentFragment.CreateDocumentFragmentWrapper(_domDocument.CreateDocumentFragment()));
 }
        private IDocumentFragment ConstructNewDocumentFragment(string elementName, IPluglet currentPluglet, IDocumentFragment currentDocumentFragment)
        {
            IDocumentFragment newDocumentPluglet = null;

            IPluglet nextPluglet = null;

            // Special case for root pluglet
            if (CurrentElementNumber == 0)
            {
                nextPluglet = currentPluglet;

                string rootNodeName = elementName;
                int    pos          = elementName.IndexOf(":");
                if (pos != -1)
                {
                    rootNodeName = elementName.Substring(pos + 1);
                }

                if (string.Equals(nextPluglet.Tag, rootNodeName, StringComparison.InvariantCultureIgnoreCase) == false)
                {
                    Errors.AddSegmentError(elementName, -1,
                                           string.Format("Invalid root node name. Expected: {0}, Actual {1}", nextPluglet.Tag, rootNodeName), CurrentElementNumber,
                                           CurrentLinePayloadStart + TotalPayloadLength, CurrentLinePayloadEnd + TotalPayloadLength, EdiErrorType.Error);
                }
            }
            else
            {
                foreach (IPluglet childPluglet in currentPluglet.Children)
                {
                    if (string.Equals(childPluglet.Tag, elementName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        nextPluglet = childPluglet;
                        break;
                    }
                }
            }

            if (nextPluglet == null)
            {
                Errors.AddSegmentError(elementName, X12ErrorCode.UnrecognizedSegmentIDCode,
                                       X12ErrorCode.GetStandardSegmentErrorDescription(X12ErrorCode.UnrecognizedSegmentIDCode), CurrentElementNumber,
                                       CurrentLinePayloadStart + TotalPayloadLength, CurrentLinePayloadEnd + TotalPayloadLength, EdiErrorType.Error);
                // TODO: Should we add 'Unrecognized segment' pluglet here?
            }
            else
            {
                newDocumentPluglet = new DocumentFragment()
                {
                    Parent  = currentDocumentFragment,
                    Pluglet = nextPluglet,
                    Value   = elementName,
                };

                if (currentDocumentFragment.Children == null)
                {
                    ((DocumentFragment)currentDocumentFragment).Children = new List <IDocumentFragment>();
                }

                currentDocumentFragment.Children.Add(newDocumentPluglet);
            }

            return(newDocumentPluglet);
        }
 public HtmlTemplateElement(Document owner, String prefix = null)
     : base(owner, Tags.Template, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTableScoped | NodeFlags.HtmlTableSectionScoped)
 {
     _content = new DocumentFragment(owner);
 }
Exemple #34
0
 public HtmlTemplateElement(Document owner)
     : base(owner, Tags.Template, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTableScoped | NodeFlags.HtmlTableSectionScoped)
 {
     _content = new DocumentFragment(owner);
 }
Exemple #35
0
 public HTMLTemplateElement(Document document, DocumentFragment content) : this(document, content, "template")
 {
 }