Ejemplo n.º 1
0
        public static BaseItem Fabrica(ODFDocument document, XmlNode xmlElement, DocumentElementCollection ownerItem)
        {
            BaseItem item = Fabrica(document, xmlElement);

            item.Owner = ownerItem;
            return(item);
        }
Ejemplo n.º 2
0
        public static void SeparateItem(DocumentElementCollection toSeparate, BaseItem separator)
        {
            DocumentElementCollection r = SeparateSubItem(toSeparate, separator);

            if (r != null)
            {
                toSeparate.Owner.InsertAfter(toSeparate, r);
            }
        }
Ejemplo n.º 3
0
        public static DocumentElementCollection SeparateSubItem(DocumentElementCollection toSeparate, BaseItem separator)
        {
            if (toSeparate == separator)
            {
                return(null);
            }
            BaseItem entry = GetEntryElement(toSeparate, separator);
            DocumentElementCollection result = null;

            if (entry == separator)
            {
                if (separator.IsLastElement)
                {
                    return(null);
                }
                result = toSeparate.Clone() as DocumentElementCollection;
                result.Clear();

                int index = toSeparate.IndexOf(separator) + 1;
                while (index < toSeparate.Count)
                {
                    BaseItem bi = toSeparate[index];
                    toSeparate.Remove(bi);
                    result.Add(bi);
                    //index++;
                }
            }
            else if (!entry.IsLastElement)
            {
                result = toSeparate.Clone() as DocumentElementCollection;
                result.Clear();

                DocumentElementCollection item = SeparateSubItem((DocumentElementCollection)entry, separator);
                if (item != null)
                {
                    result.Add(item);
                }

                int index = toSeparate.IndexOf(entry) + 1;
                while (index < toSeparate.Count)
                {
                    BaseItem bi = toSeparate[index];
                    toSeparate.Remove(bi);
                    result.Add(bi);
                    //index++;
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static string GetText(DocumentElementCollection item)
        {
            var sez = new StringBuilder();

            foreach (BaseItem bi in item)
            {
                if (bi is ITextContainer)
                {
                    sez.Append(((ITextContainer)bi).Value);
                }
                else if (bi is ITextual)
                {
                    sez.Append(((ITextual)bi).Value);
                }
            }
            return(sez.ToString());
        }
Ejemplo n.º 5
0
 public static BaseItem GetEntryElement(DocumentElementCollection paragraph, BaseItem afterElement)
 {
     if (paragraph.Contains(afterElement))
     {
         return(afterElement);
     }
     foreach (BaseItem bi in (DocumentElementCollection)paragraph)
     {
         if (bi is DocumentElementCollection)
         {
             BaseItem entry = GetEntryElement((DocumentElementCollection)bi, afterElement);
             if (entry == afterElement)
             {
                 return(bi);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 6
0
 public static List <TableStyle> GetTableStyles(DocumentElementCollection element)
 {
     return(GetChildsRecursive(element, typeof(TableStyle)).ConvertAll <TableStyle>(new Converter <BaseItem, TableStyle>(BaseToTableStyle)));
 }
Ejemplo n.º 7
0
 public static List <FrameImage> GetImages(DocumentElementCollection element)
 {
     return(GetChildsRecursive(element, typeof(FrameImage)).ConvertAll <FrameImage>(new Converter <BaseItem, FrameImage>(BaseToImage)));
 }
Ejemplo n.º 8
0
 internal static List <GraphicStyle> GetGraphicStyles(DocumentElementCollection element)
 {
     return(GetChildsRecursive(element, typeof(GraphicStyle)).ConvertAll <GraphicStyle>(new Converter <BaseItem, GraphicStyle>(BaseToGraphic)));
 }
Ejemplo n.º 9
0
        public static BaseItem Fabrica(ODFDocument d, XmlNode xn)
        {
            if (xn is XmlText)
            {
                return(new TextElement(d, (XmlText)xn));
            }
            XmlElement xe = xn as XmlElement;
            BaseItem   it = null;

            if (xe == null)
            {
            }
            if (xe.Name == FontFace)
            {
                it = new FontFace(d, xe);
            }

            else if (xe.Name == DateStyle)
            {
                it = new DateStyle(d, xe);
            }
            else if (xe.Name == TimeStyle)
            {
                it = new TimeStyle(d, xe);
            }
            else if (xe.Name == TableOfContent)
            {
                it = new TableOfContent(d, xe);
            }
            else if (xe.Name == TableOfContentSource)
            {
                it = new TableOfContentSource(d, xe);
            }
            else if (xe.Name == TableOfContentEntryTemplate)
            {
                it = new TableOfContentEntryTemplate(d, xe);
            }
            else if (xe.Name == IndexTitleTemplate)
            {
                it = new IndexTitleTemplate(d, xe);
            }
            else if (xe.Name == IndexEntryLinkStart)
            {
                it = new IndexEntryLinkStart(d, xe);
            }
            else if (xe.Name == IndexEntrySpan)
            {
                it = new IndexEntrySpan(d, xe);
            }
            else if (xe.Name == IndexEntryText)
            {
                it = new IndexEntryText(d, xe);
            }
            else if (xe.Name == IndexEntryTabStop)
            {
                it = new IndexEntryTabStop(d, xe);
            }
            else if (xe.Name == IndexEntryPageNumber)
            {
                it = new IndexEntryPageNumber(d, xe);
            }
            else if (xe.Name == IndexEntryLinkEnd)
            {
                it = new IndexEntryLinkEnd(d, xe);
            }
            else if (xe.Name == IndexBody)
            {
                it = new IndexBody(d, xe);
            }

            else if (xe.Name == TextBibliographyConfiguration)
            {
                it = new TextBibliographyConfiguration(d, xe);
            }
            else if (xe.Name == TextSortKey)
            {
                it = new TextSortKey(d, xe);
            }

            else if (xe.Name == DrawTextBox)
            {
                it = new DrawTextBox(d, xe);
            }
            else if (xe.Name == SoftPageBreak)
            {
                it = new SoftPageBreak(d, xe);
            }
            else if (xe.Name == TextHeader)
            {
                it = new TextHeader(d, xe);
            }
            else if (xe.Name == TextLink)
            {
                it = new TextLink(d, xe);
            }
            else if (xe.Name == TextSection)
            {
                it = new TextSection(d, xe);
            }
            else if (xe.Name == TextSpace)
            {
                it = new TextSpace(d, xe);
            }
            else if (xe.Name == TextTab)
            {
                it = new TextTab(d, xe);
            }
            else if (xe.Name == PageLayout)
            {
                it = new PageLayout(d, xe);
            }
            else if (xe.Name == PageLayoutProperties)
            {
                it = new PageLayoutProperties(d, xe);
            }

            else if (xe.Name == MasterPage)
            {
                it = new MasterPage(d, xe);
            }

            else if (xe.Name == Frame)
            {
                it = new Frame(d, xe);
            }
            else if (xe.Name == FrameImage)
            {
                it = new FrameImage(d, xe);
            }

            else if (xe.Name == List)
            {
                it = new List(d, xe);
            }
            else if (xe.Name == ListItem)
            {
                it = new ListItem(d, xe);
            }

            else if (xe.Name == NotesConfiguration)
            {
                it = new NotesConfiguration(d, xe);
            }
            else if (xe.Name == LineNumberingConfiguration)
            {
                it = new LineNumberingConfiguration(d, xe);
            }

            else if (xe.Name == ListStyle)
            {
                it = new ListStyle(d, xe);
            }
            else if (xe.Name == ListLevelStyleBullet)
            {
                it = new ListLevelStyleBullet(d, xe);
            }
            else if (xe.Name == ListLevelStyleNumber)
            {
                it = new ListLevelStyleNumber(d, xe);
            }
            else if (xe.Name == ListLevelProperties)
            {
                it = new ListLevelProperties(d, xe);
            }
            else if (xe.Name == ListLevelLableAligment)
            {
                it = new ListLevelLableAligment(d, xe);
            }
            else if (xe.Name == OutlineStyle)
            {
                it = new OutlineStyle(d, xe);
            }
            else if (xe.Name == OutlineLevelStyle)
            {
                it = new OutlineLevelStyle(d, xe);
            }

            else if (xe.Name == ParagraphProperties)
            {
                it = new ParagraphProperties(d, xe);
            }
            else if (xe.Name == TabStops)
            {
                it = new TabStops(d, xe);
            }
            else if (xe.Name == TabStop)
            {
                it = new TabStop(d, xe);
            }
            else if (xe.Name == TextProperties)
            {
                it = new TextProperties(d, xe);
            }
            else if (xe.Name == TableProperties)
            {
                it = new TableProperties(d, xe);
            }
            else if (xe.Name == ColumnProperties)
            {
                it = new ColumnProperties(d, xe);
            }
            else if (xe.Name == CellProperties)
            {
                it = new CellProperties(d, xe);
            }
            else if (xe.Name == GraphicProperties)
            {
                it = new GraphicProperties(d, xe);
            }
            else if (xe.Name == SectionProperties)
            {
                it = new SectionProperties(d, xe);
            }
            else if (xe.Name == BackgroundImageStyle)
            {
                it = new BackgroundImageStyle(d, xe);
            }
            else if (xe.Name == ColumnsStyle)
            {
                it = new ColumnsStyle(d, xe);
            }

            else if (xe.Name == Paragraph)
            {
                it = new Paragraph(d, xe);
            }
            else if (xe.Name == TextSpan)
            {
                it = new TextSpan(d, xe);
            }
            else if (xe.Name == Placeholder)
            {
                it = new Placeholder(d, xe);
            }
            else if (xe.Name == Table)
            {
                it = new Table(d, xe);
            }
            else if (xe.Name == CoveredCell)
            {
                it = new CoveredCell(d, xe);
            }
            else if (xe.Name == Column)
            {
                it = new Column(d, xe);
            }
            else if (xe.Name == Row)
            {
                it = new Row(d, xe);
            }
            else if (xe.Name == Cell)
            {
                it = new Cell(d, xe);
            }
            else if (xe.Name == TableCalculationSettings)
            {
                it = new TableCalculationSettings(d, xe);
            }
            else if (xe.Name == DocumentStyles)
            {
                it = new DocumentStyles(d, xe);
            }
            else if (xe.Name == Styles)
            {
                it = new Styles(d, xe);
            }

            else if (xe.Name == Style)
            {
                string buf = xe.GetAttribute("style:family");
                if (buf == "graphic")
                {
                    it = new GraphicStyle(d, xe);
                }
                else if (buf == "paragraph")
                {
                    it = new ParagraphStyle(d, xe);
                }
                else if (buf == "table")
                {
                    it = new TableStyle(d, xe);
                }
                else if (buf == "table-row")
                {
                    it = new RowStyle(d, xe);
                }
                else if (buf == "table-column")
                {
                    it = new ColumnStyle(d, xe);
                }
                else if (buf == "table-cell")
                {
                    it = new CellStyle(d, xe);
                }
                else if (buf == "text")
                {
                    it = new TextStyle(d, xe);
                }
                else if (buf == "section")
                {
                    it = new SectionStyle(d, xe);
                }
                else
                {
                    it = new DefaultStyle(d, xe);
                }
            }
            else if (xe.Name == CurrencyStyle)
            {
                it = new CurrencyStyle(d, xe);
            }
            else if (xe.Name == NumberStyle)
            {
                it = new NumberStyle(d, xe);
            }
            else if (xe.Name == NumberTextStyle)
            {
                it = new NumberTextStyle(d, xe);
            }
            else if (xe.Name == Number)
            {
                it = new Number(d, xe);
            }
            else if (xe.Name == NumberText)
            {
                it = new NumberText(d, xe);
            }
            else if (xe.Name == DefaultStyle)
            {
                it = new DefaultStyle(d, xe);
            }
            else if (xe.Name == FontFaceDeclarations)
            {
                it = new FontFaceDeclarations(d, xe);
            }
            else if (xe.Name == DocumentContent)
            {
                it = new DocumentContent(d, xe);
            }
            else if (xe.Name == Scripts)
            {
                it = new Scripts(d, xe);
            }
            else if (xe.Name == AutomaticStyles)
            {
                it = new AutomaticStyles(d, xe);
            }
            else if (xe.Name == MasterStyles)
            {
                it = new MasterStyles(d, xe);
            }

            else if (xe.Name == DocumentSpreadSheet)
            {
                it = new DocumentSpreadSheet(d, xe);
            }
            else if (xe.Name == DocumentBody)
            {
                it = new DocumentBody(d, xe);
            }
            else if (xe.Name == DocumentText)
            {
                it = new BodyText(d, xe);
            }
            else if (xe.Name == TextSequeceDeclarations)
            {
                it = new TextSequenceDeclarations(d, xe);
            }
            else if (xe.Name == TextSequeceDeclaration)
            {
                it = new TextSequenceDeclaration(d, xe);
            }


            else if (xe.Name == DocumentMeta)
            {
                it = new DocumentMeta(d, xe);
            }
            else if (xe.Name == Meta)
            {
                it = new Meta(d, xe);
            }
            else if (xe.Name == MetaInitialCreator)
            {
                it = new MetaInitialCreator(d, xe);
            }
            else if (xe.Name == MetaCreationDate)
            {
                it = new MetaCreationDate(d, xe);
            }
            else if (xe.Name == MetaDate)
            {
                it = new MetaDate(d, xe);
            }
            else if (xe.Name == MetaCreator)
            {
                it = new MetaCreator(d, xe);
            }
            else if (xe.Name == MetaEditingDuration)
            {
                it = new MetaEditiongDuration(d, xe);
            }
            else if (xe.Name == MetaEditingCycles)
            {
                it = new MetaEditiongCycles(d, xe);
            }
            else if (xe.Name == MetaGenerator)
            {
                it = new MetaGenerator(d, xe);
            }
            else if (xe.Name == MetaStatistic)
            {
                it = new MetaStatistic(d, xe);
            }

            else if (xe.Name == DocumentManifest)
            {
                it = new DocumentManifest(d, xe);
            }
            else if (xe.Name == ManifestFile)
            {
                it = new ManifestFile(d, xe);
            }

            else if (xe.Name == DocumentSettings)
            {
                it = new DocumentSettings(d, xe);
            }
            else if (xe.Name == Settings)
            {
                it = new Settings(d, xe);
            }
            else if (xe.Name == ConfigItemSet)
            {
                it = new ConfigItemSet(d, xe);
            }
            else if (xe.Name == ConfigItem)
            {
                it = new ConfigItem(d, xe);
            }
            else if (xe.Name == ConfigItemMapIndexed)
            {
                it = new ConfigItemMapIndexed(d, xe);
            }
            else if (xe.Name == ConfigItemMapEntry)
            {
                it = new ConfigItemMapEntry(d, xe);
            }

            else
            {
                it = new DocumentElementCollection(d, xe);
            }
            return(it);
        }
Ejemplo n.º 10
0
        public static void Replace(BaseItem oldItem, BaseItem newItem)
        {
            DocumentElementCollection owner = oldItem.Owner;

            owner.Replace(oldItem, newItem);
        }
Ejemplo n.º 11
0
 public static List <Placeholder> GetPlaceholders(DocumentElementCollection element)
 {
     return(GetChildsRecursive(element, typeof(Placeholder)).ConvertAll <Placeholder>(new Converter <BaseItem, Placeholder>(BaseToPlaceholder)));
 }
Ejemplo n.º 12
0
 public static List <SectionStyle> GetSectionStyles(DocumentElementCollection element)
 {
     return(GetChildsRecursive(element, typeof(SectionStyle)).ConvertAll <SectionStyle>(new Converter <BaseItem, SectionStyle>(BaseToSectionStyle)));;
 }
Ejemplo n.º 13
0
 public static List <ParagraphStyle> GetParagraphStyles(DocumentElementCollection element)
 {
     return(GetChildsRecursive(element, typeof(ParagraphStyle)).ConvertAll <ParagraphStyle>(new Converter <BaseItem, ParagraphStyle>(BaseToParagraphStyle)));
 }