1/* contentfactory.vala 2 * 3 * Copyright (C) 2008-2009 Didier Villevalois 4 * Copyright (C) 2008-2012 Florian Brosch 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 * Author: 21 * Didier 'Ptitjes Villevalois <ptitjes@free.fr> 22 */ 23 24 25public class Valadoc.Content.ContentFactory : Object { 26 27 public ContentFactory (Settings settings, ResourceLocator locator, ModuleLoader modules) { 28 _settings = settings; 29 _locator = locator; 30 _modules = modules; 31 } 32 33 private Settings _settings; 34 private ResourceLocator _locator; 35 private ModuleLoader _modules; 36 37 private inline ContentElement configure (ContentElement element) { 38 element.configure (_settings, _locator); 39 return element; 40 } 41 42 public Comment create_comment () { 43 return (Comment) configure (new Comment ()); 44 } 45 46 public Embedded create_embedded () { 47 return (Embedded) configure (new Embedded ()); 48 } 49 50 public Headline create_headline () { 51 return (Headline) configure (new Headline ()); 52 } 53 54 public Link create_link () { 55 return (Link) configure (new Link ()); 56 } 57 58 public WikiLink create_wiki_link () { 59 return (WikiLink) configure (new WikiLink ()); 60 } 61 62 public List create_list () { 63 return (List) configure (new List ()); 64 } 65 66 public ListItem create_list_item () { 67 return (ListItem) configure (new ListItem ()); 68 } 69 70 public Page create_page () { 71 return (Page) configure (new Page ()); 72 } 73 74 public Paragraph create_paragraph () { 75 return (Paragraph) configure (new Paragraph ()); 76 } 77 78 public Warning create_warning () { 79 return (Warning) configure (new Warning ()); 80 } 81 public Note create_note () { 82 return (Note) configure (new Note ()); 83 } 84 85 public Run create_run (Run.Style style) { 86 return (Run) configure (new Run (style)); 87 } 88 89 public SourceCode create_source_code () { 90 return (SourceCode) configure (new SourceCode ()); 91 } 92 93 public Table create_table () { 94 return (Table) configure (new Table ()); 95 } 96 97 public TableCell create_table_cell () { 98 return (TableCell) configure (new TableCell ()); 99 } 100 101 public TableRow create_table_row () { 102 return (TableRow) configure (new TableRow ()); 103 } 104 105 public Taglet? create_taglet (string name) { 106 return _modules.create_taglet (name); 107 } 108 109 public Text create_text (string? text = null) { 110 return (Text) configure (new Text (text)); 111 } 112 113 public ContentElement set_style_attributes (StyleAttributes element, 114 VerticalAlign? valign, 115 HorizontalAlign? halign, 116 string? style) { 117 element.vertical_align = valign; 118 element.horizontal_align = halign; 119 element.style = style; 120 return element; 121 } 122} 123