Class: Uniword::Wordprocessingml::ParagraphStyle
- Inherits:
-
Object
- Object
- Uniword::Wordprocessingml::ParagraphStyle
- Defined in:
- lib/uniword/wordprocessingml/paragraph_style.rb
Overview
Factory class for creating paragraph Style instances
Provides factory methods for common paragraph styles like Normal, Heading1-9, etc.
Class Method Summary collapse
-
.create_heading_paragraph_properties(level) ⇒ ParagraphProperties
Create paragraph properties for heading styles.
-
.create_heading_run_properties(level) ⇒ RunProperties
Create run properties for heading styles.
-
.heading(level) ⇒ Style
Create a Heading style for the given level.
-
.intense_quote ⇒ Style
Create an Intense Quote style.
-
.normal ⇒ Style
Create a Normal paragraph style.
-
.quote ⇒ Style
Create a Quote style.
-
.subtitle ⇒ Style
Create a Subtitle style.
-
.title ⇒ Style
Create a Title style.
Class Method Details
.create_heading_paragraph_properties(level) ⇒ ParagraphProperties
Create paragraph properties for heading styles
130 131 132 133 134 135 136 137 138 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 130 def self.create_heading_paragraph_properties(level) outline_level = [level - 1, 0].max ParagraphProperties.new( outline_level: Properties::OutlineLevel.new(value: outline_level.to_s), spacing: Properties::Spacing.new(before: (240 + (level * 80)).to_s, after: "0"), ) end |
.create_heading_run_properties(level) ⇒ RunProperties
Create run properties for heading styles
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 144 def self.create_heading_run_properties(level) sizes = { 1 => "32", 2 => "26", 3 => "24", 4 => "22", 5 => "20", 6 => "20", 7 => "20", 8 => "20", 9 => "20" } fonts = { 1 => "Calibri Light", 2 => "Calibri Light", 3 => "Calibri", 4 => "Calibri", 5 => "Calibri", 6 => "Calibri", 7 => "Calibri", 8 => "Calibri", 9 => "Calibri" } colors = { 1 => "2E74B5", 2 => "2E74B5", 3 => "1F4E79", 4 => "2E74B5", 5 => "2E74B5", 6 => "1F3763", 7 => "2E74B5", 8 => "2E74B5", 9 => "2E74B5" } RunProperties.new( size: Properties::FontSize.new(value: sizes[level]), fonts: Properties::RunFonts.new(ascii: fonts[level], h_ansi: fonts[level]), color: Properties::ColorValue.new(value: colors[level]), bold: Properties::Bold.new, ) end |
.heading(level) ⇒ Style
Create a Heading style for the given level
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 27 def self.heading(level) unless (1..9).cover?(level) raise ArgumentError, "Heading level must be 1-9" end Style.new( type: "paragraph", styleId: "Heading#{level}", name: StyleName.new(val: "Heading #{level}"), basedOn: BasedOn.new(val: "Normal"), nextStyle: Next.new(val: "Normal"), uiPriority: UiPriority.new(val: (level + 8).to_s), qFormat: Properties::QuickFormat.new, pPr: create_heading_paragraph_properties(level), rPr: create_heading_run_properties(level), ) end |
.intense_quote ⇒ Style
Create an Intense Quote style
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 111 def self.intense_quote Style.new( type: "paragraph", styleId: "IntenseQuote", name: StyleName.new(val: "Intense Quote"), basedOn: BasedOn.new(val: "Quote"), nextStyle: Next.new(val: "Normal"), uiPriority: UiPriority.new(val: "30"), qFormat: Properties::QuickFormat.new, rPr: RunProperties.new( bold: Properties::Bold.new, ), ) end |
.normal ⇒ Style
Create a Normal paragraph style
13 14 15 16 17 18 19 20 21 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 13 def self.normal Style.new( type: "paragraph", styleId: "Normal", default: true, name: StyleName.new(val: "Normal"), qFormat: Properties::QuickFormat.new, ) end |
.quote ⇒ Style
Create a Quote style
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 90 def self.quote Style.new( type: "paragraph", styleId: "Quote", name: StyleName.new(val: "Quote"), basedOn: BasedOn.new(val: "Normal"), nextStyle: Next.new(val: "Normal"), uiPriority: UiPriority.new(val: "29"), qFormat: Properties::QuickFormat.new, pPr: ParagraphProperties.new( indentation: Properties::Indentation.new(left: "720"), ), rPr: RunProperties.new( italic: Properties::Italic.new, ), ) end |
.subtitle ⇒ Style
Create a Subtitle style
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 69 def self.subtitle Style.new( type: "paragraph", styleId: "Subtitle", name: StyleName.new(val: "Subtitle"), basedOn: BasedOn.new(val: "Normal"), nextStyle: Next.new(val: "Normal"), uiPriority: UiPriority.new(val: "11"), qFormat: Properties::QuickFormat.new, rPr: RunProperties.new( color: Properties::ColorValue.new(value: "595959"), size: Properties::FontSize.new(value: "28"), fonts: Properties::RunFonts.new(ascii: "Calibri Light", h_ansi: "Calibri Light"), ), ) end |
.title ⇒ Style
Create a Title style
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/uniword/wordprocessingml/paragraph_style.rb', line 49 def self.title Style.new( type: "paragraph", styleId: "Title", name: StyleName.new(val: "Title"), basedOn: BasedOn.new(val: "Normal"), nextStyle: Next.new(val: "Normal"), uiPriority: UiPriority.new(val: "10"), qFormat: Properties::QuickFormat.new, rPr: RunProperties.new( size: Properties::FontSize.new(value: "56"), fonts: Properties::RunFonts.new(ascii: "Calibri Light", h_ansi: "Calibri Light"), ), ) end |