rrtf 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -7
- data/documentation/RRTF/CharacterFormatting.html +1002 -0
- data/documentation/RRTF/CharacterStyle.html +1058 -0
- data/documentation/RRTF/Colour.html +813 -0
- data/documentation/RRTF/ColourTable.html +770 -0
- data/documentation/RRTF/CommandNode.html +2372 -0
- data/documentation/RRTF/ContainerNode.html +826 -0
- data/documentation/RRTF/Converters/HTML/Helpers.html +272 -0
- data/documentation/RRTF/Converters/HTML/Node.html +364 -0
- data/documentation/RRTF/Converters/HTML/NodeSet.html +265 -0
- data/documentation/RRTF/Converters/HTML.html +337 -0
- data/documentation/RRTF/Converters.html +117 -0
- data/documentation/RRTF/Document.html +2405 -0
- data/documentation/RRTF/DocumentStyle.html +1367 -0
- data/documentation/RRTF/Font.html +790 -0
- data/documentation/RRTF/FontTable.html +763 -0
- data/documentation/RRTF/FooterNode.html +515 -0
- data/documentation/RRTF/HeaderNode.html +515 -0
- data/documentation/RRTF/ImageNode.html +1374 -0
- data/documentation/RRTF/Information.html +809 -0
- data/documentation/RRTF/LinkNode.html +264 -0
- data/documentation/RRTF/ListLevel.html +799 -0
- data/documentation/RRTF/ListLevelNode.html +612 -0
- data/documentation/RRTF/ListMarker.html +595 -0
- data/documentation/RRTF/ListNode.html +368 -0
- data/documentation/RRTF/ListTable.html +343 -0
- data/documentation/RRTF/ListTemplate.html +433 -0
- data/documentation/RRTF/ListTextNode.html +285 -0
- data/documentation/RRTF/Node.html +616 -0
- data/documentation/RRTF/Paper.html +624 -0
- data/documentation/RRTF/ParagraphFormatting.html +749 -0
- data/documentation/RRTF/ParagraphNode.html +275 -0
- data/documentation/RRTF/ParagraphStyle.html +1319 -0
- data/documentation/RRTF/RTFError.html +295 -0
- data/documentation/RRTF/Style.html +1767 -0
- data/documentation/RRTF/Stylesheet.html +1768 -0
- data/documentation/RRTF/TableCellNode.html +1704 -0
- data/documentation/RRTF/TableNode.html +1025 -0
- data/documentation/RRTF/TableRowNode.html +675 -0
- data/documentation/RRTF/TextNode.html +600 -0
- data/documentation/RRTF/Utilities.html +201 -0
- data/documentation/RRTF.html +129 -0
- data/documentation/_index.html +478 -0
- data/documentation/class_list.html +51 -0
- data/documentation/css/common.css +1 -0
- data/documentation/css/full_list.css +58 -0
- data/documentation/css/style.css +492 -0
- data/documentation/file.README.html +223 -0
- data/documentation/file_list.html +56 -0
- data/documentation/frames.html +17 -0
- data/documentation/index.html +223 -0
- data/documentation/js/app.js +248 -0
- data/documentation/js/full_list.js +216 -0
- data/documentation/js/jquery.js +4 -0
- data/documentation/method_list.html +2203 -0
- data/documentation/top-level-namespace.html +110 -0
- data/examples/01.rtf +14 -17
- data/examples/01_mac_word15_36.png +0 -0
- data/examples/01_styles_and_paragraphs.rb +3 -4
- data/examples/resources/json/redshirt_styles.json +4 -2
- data/lib/rrtf/node.rb +86 -167
- data/lib/rrtf/style/character_style.rb +4 -3
- data/lib/rrtf/style/formatting.rb +55 -11
- data/lib/rrtf/style/paragraph_style.rb +19 -4
- data/lib/rrtf/style/style.rb +15 -15
- data/lib/rrtf/stylesheet.rb +57 -16
- data/lib/rrtf/version.rb +1 -1
- data/rrtf.gemspec +1 -0
- metadata +70 -1
@@ -0,0 +1,110 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Top Level Namespace</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Top Level Namespace
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<h2>Defined Under Namespace</h2>
|
82
|
+
<p class="children">
|
83
|
+
|
84
|
+
|
85
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="RRTF.html" title="RRTF (module)">RRTF</a></span>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
</p>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div id="footer">
|
103
|
+
Generated on Mon Jul 24 15:48:59 2017 by
|
104
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
+
0.9.9 (ruby-2.3.3).
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</body>
|
110
|
+
</html>
|
data/examples/01.rtf
CHANGED
@@ -7,39 +7,36 @@
|
|
7
7
|
\red255\green0\blue0;
|
8
8
|
}
|
9
9
|
{\stylesheet
|
10
|
-
{\s1 \qc\sa100\ltrpar
|
11
|
-
{\s2 \ql\sb200\sa40\ltrpar
|
12
|
-
{\
|
13
|
-
{\*\
|
10
|
+
{\s1 \qc\sa100\ltrpar\b\uldb\caps\ulc1\fs36 \sbasedon0 \sautoupd \snext0 \sqformat \spriority1 Title;}
|
11
|
+
{\s2 \ql\sb200\sa40\ltrpar\b\ul\ulc1\fs24 \snext0 \sqformat \spriority2 Heading 1;}
|
12
|
+
{\s0 \ql\hyphpar\ltrpar\fs24 \sqformat \spriority3 Normal;}
|
13
|
+
{\*\cs3 \b\i\cf1 \additive \spriority4 Emphasis;}
|
14
14
|
}
|
15
15
|
{\info
|
16
|
-
{\createim\yr2017\mo7\
|
16
|
+
{\createim\yr2017\mo7\dy24\hr15\min51}
|
17
17
|
}
|
18
18
|
|
19
19
|
\stylesortmethod1\paperw12247\paperh15819\margl1800\margr1800\margt1440\margb1440
|
20
|
-
{\pard\s1 \qc\sa100\ltrpar
|
20
|
+
{\pard\s1 \qc\sa100\ltrpar\b\uldb\caps\ulc1\fs36
|
21
21
|
RedShirts 101
|
22
22
|
\par}
|
23
|
-
{\pard\
|
23
|
+
{\pard\s0 \ql\hyphpar\ltrpar\fs24
|
24
24
|
Should you ever find yourself on a spacefaring vessel wearing a
|
25
|
-
{\
|
25
|
+
{\cs3 \b\i\cf1
|
26
26
|
red
|
27
27
|
}
|
28
28
|
shirt, take heed and be on guard, for danger is immanent and you are likely expendable among the crew...
|
29
29
|
\par}
|
30
|
-
{\pard\s2 \ql\sb200\sa40\ltrpar
|
30
|
+
{\pard\s2 \ql\sb200\sa40\ltrpar\b\ul\ulc1\fs24
|
31
31
|
1. The Danger of Away Missions
|
32
32
|
\par}
|
33
|
-
{\pard\
|
34
|
-
If you're ever assigned an away mission,
|
33
|
+
{\pard\s0 \ql\hyphpar\ltrpar\fs24
|
34
|
+
If you're ever assigned an away mission, it's almost certain to be your doom. The optimal strategy is to avoid away missions to begin with...
|
35
35
|
\par}
|
36
|
-
{\pard\s2 \ql\sb200\sa40\ltrpar
|
36
|
+
{\pard\s2 \ql\sb200\sa40\ltrpar\b\ul\ulc1\fs24
|
37
37
|
2. Avoiding High-Ranking Officers
|
38
38
|
\par}
|
39
|
-
{\pard\
|
40
|
-
You're likely to notice an influx of unfortunate outcomes around
|
41
|
-
\par}
|
42
|
-
{\pard\s2 \ql\sb200\sa40\ltrpar \b\ul\ulc1\fs24
|
43
|
-
3. Miscellaneous Hazards
|
39
|
+
{\pard\s0 \ql\hyphpar\ltrpar\fs24
|
40
|
+
You're likely to notice an influx of unfortunate outcomes around certain high-ranking officers. Its to your advantage to quickly identify and avoid these officers...
|
44
41
|
\par}
|
45
42
|
}
|
Binary file
|
@@ -17,17 +17,16 @@ rtf.paragraph(styles['BODY']) do |p|
|
|
17
17
|
end
|
18
18
|
rtf.paragraph(styles['H1']) << "1. The Danger of Away Missions"
|
19
19
|
rtf.paragraph(styles['BODY']) do |p|
|
20
|
-
p << "If you're ever assigned an away mission,
|
21
|
-
p << "The optimal
|
20
|
+
p << "If you're ever assigned an away mission, it's almost certain to be your doom. "
|
21
|
+
p << "The optimal strategy is to avoid away missions to begin with..."
|
22
22
|
end
|
23
23
|
rtf.paragraph(styles['H1']) << "2. Avoiding High-Ranking Officers"
|
24
24
|
rtf.paragraph(styles['BODY']) do |p|
|
25
25
|
p << "You're likely to notice an influx of unfortunate outcomes around "
|
26
|
-
p << "
|
26
|
+
p << "certain high-ranking officers. Its to your advantage to quickly identify and "
|
27
27
|
p << "avoid these officers..."
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
30
|
File.open(DIR+'/01.rtf', 'w') do |file|
|
32
31
|
file.write(rtf.to_rtf)
|
33
32
|
end
|
@@ -31,8 +31,9 @@
|
|
31
31
|
{
|
32
32
|
"type": "paragraph",
|
33
33
|
"id": "BODY",
|
34
|
-
"name": "
|
34
|
+
"name": "Normal",
|
35
35
|
"primary": true,
|
36
|
+
"default": true,
|
36
37
|
"justification": "LEFT",
|
37
38
|
"font_size": 24,
|
38
39
|
"hyphenate": true
|
@@ -44,6 +45,7 @@
|
|
44
45
|
"additive": true,
|
45
46
|
"italic": true,
|
46
47
|
"bold": true,
|
47
|
-
"foreground_color": "#ff0000"
|
48
|
+
"foreground_color": "#ff0000",
|
49
|
+
"locked": true
|
48
50
|
}
|
49
51
|
]
|
data/lib/rrtf/node.rb
CHANGED
@@ -1515,150 +1515,65 @@ module RRTF
|
|
1515
1515
|
# This class represents an RTF document. In actuality it is just a
|
1516
1516
|
# specialised Node type that cannot be assigned a parent and that holds
|
1517
1517
|
# document font, colour and information tables.
|
1518
|
+
# @author Peter Wood
|
1518
1519
|
class Document < CommandNode
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
# A definition for a document character set setting.
|
1529
|
-
CS_PCA = :pca
|
1530
|
-
|
1531
|
-
# A definition for a document language setting.
|
1532
|
-
LC_AFRIKAANS = 1078
|
1533
|
-
|
1534
|
-
# A definition for a document language setting.
|
1535
|
-
LC_ARABIC = 1025
|
1536
|
-
|
1537
|
-
# A definition for a document language setting.
|
1538
|
-
LC_CATALAN = 1027
|
1539
|
-
|
1540
|
-
# A definition for a document language setting.
|
1541
|
-
LC_CHINESE_TRADITIONAL = 1028
|
1542
|
-
|
1543
|
-
# A definition for a document language setting.
|
1544
|
-
LC_CHINESE_SIMPLIFIED = 2052
|
1545
|
-
|
1546
|
-
# A definition for a document language setting.
|
1547
|
-
LC_CZECH = 1029
|
1548
|
-
|
1549
|
-
# A definition for a document language setting.
|
1550
|
-
LC_DANISH = 1030
|
1551
|
-
|
1552
|
-
# A definition for a document language setting.
|
1553
|
-
LC_DUTCH = 1043
|
1554
|
-
|
1555
|
-
# A definition for a document language setting.
|
1556
|
-
LC_DUTCH_BELGIAN = 2067
|
1557
|
-
|
1558
|
-
# A definition for a document language setting.
|
1559
|
-
LC_ENGLISH_UK = 2057
|
1560
|
-
|
1561
|
-
# A definition for a document language setting.
|
1562
|
-
LC_ENGLISH_US = 1033
|
1563
|
-
|
1564
|
-
# A definition for a document language setting.
|
1565
|
-
LC_FINNISH = 1035
|
1566
|
-
|
1567
|
-
# A definition for a document language setting.
|
1568
|
-
LC_FRENCH = 1036
|
1569
|
-
|
1570
|
-
# A definition for a document language setting.
|
1571
|
-
LC_FRENCH_BELGIAN = 2060
|
1572
|
-
|
1573
|
-
# A definition for a document language setting.
|
1574
|
-
LC_FRENCH_CANADIAN = 3084
|
1575
|
-
|
1576
|
-
# A definition for a document language setting.
|
1577
|
-
LC_FRENCH_SWISS = 4108
|
1578
|
-
|
1579
|
-
# A definition for a document language setting.
|
1580
|
-
LC_GERMAN = 1031
|
1581
|
-
|
1582
|
-
# A definition for a document language setting.
|
1583
|
-
LC_GERMAN_SWISS = 2055
|
1584
|
-
|
1585
|
-
# A definition for a document language setting.
|
1586
|
-
LC_GREEK = 1032
|
1587
|
-
|
1588
|
-
# A definition for a document language setting.
|
1589
|
-
LC_HEBREW = 1037
|
1590
|
-
|
1591
|
-
# A definition for a document language setting.
|
1592
|
-
LC_HUNGARIAN = 1038
|
1593
|
-
|
1594
|
-
# A definition for a document language setting.
|
1595
|
-
LC_ICELANDIC = 1039
|
1596
|
-
|
1597
|
-
# A definition for a document language setting.
|
1598
|
-
LC_INDONESIAN = 1057
|
1599
|
-
|
1600
|
-
# A definition for a document language setting.
|
1601
|
-
LC_ITALIAN = 1040
|
1602
|
-
|
1603
|
-
# A definition for a document language setting.
|
1604
|
-
LC_JAPANESE = 1041
|
1605
|
-
|
1606
|
-
# A definition for a document language setting.
|
1607
|
-
LC_KOREAN = 1042
|
1608
|
-
|
1609
|
-
# A definition for a document language setting.
|
1610
|
-
LC_NORWEGIAN_BOKMAL = 1044
|
1611
|
-
|
1612
|
-
# A definition for a document language setting.
|
1613
|
-
LC_NORWEGIAN_NYNORSK = 2068
|
1614
|
-
|
1615
|
-
# A definition for a document language setting.
|
1616
|
-
LC_POLISH = 1045
|
1617
|
-
|
1618
|
-
# A definition for a document language setting.
|
1619
|
-
LC_PORTUGUESE = 2070
|
1620
|
-
|
1621
|
-
# A definition for a document language setting.
|
1622
|
-
LC_POTUGUESE_BRAZILIAN = 1046
|
1623
|
-
|
1624
|
-
# A definition for a document language setting.
|
1625
|
-
LC_ROMANIAN = 1048
|
1626
|
-
|
1627
|
-
# A definition for a document language setting.
|
1628
|
-
LC_RUSSIAN = 1049
|
1629
|
-
|
1630
|
-
# A definition for a document language setting.
|
1631
|
-
LC_SERBO_CROATIAN_CYRILLIC = 2074
|
1632
|
-
|
1633
|
-
# A definition for a document language setting.
|
1634
|
-
LC_SERBO_CROATIAN_LATIN = 1050
|
1635
|
-
|
1636
|
-
# A definition for a document language setting.
|
1637
|
-
LC_SLOVAK = 1051
|
1638
|
-
|
1639
|
-
# A definition for a document language setting.
|
1640
|
-
LC_SPANISH_CASTILLIAN = 1034
|
1641
|
-
|
1642
|
-
# A definition for a document language setting.
|
1643
|
-
LC_SPANISH_MEXICAN = 2058
|
1644
|
-
|
1645
|
-
# A definition for a document language setting.
|
1646
|
-
LC_SWAHILI = 1089
|
1647
|
-
|
1648
|
-
# A definition for a document language setting.
|
1649
|
-
LC_SWEDISH = 1053
|
1650
|
-
|
1651
|
-
# A definition for a document language setting.
|
1652
|
-
LC_THAI = 1054
|
1653
|
-
|
1654
|
-
# A definition for a document language setting.
|
1655
|
-
LC_TURKISH = 1055
|
1656
|
-
|
1657
|
-
# A definition for a document language setting.
|
1658
|
-
LC_UNKNOWN = 1024
|
1520
|
+
# A hash mapping character set string constants to their RTF counterparts.
|
1521
|
+
# @return [Hash<String, Symbol>] the RTF character set dictionary.
|
1522
|
+
CS_DICTIONARY = {
|
1523
|
+
"ANSI" => :ansi,
|
1524
|
+
"MAC" => :mac,
|
1525
|
+
"PC" => :pc,
|
1526
|
+
"PCA" => :pca
|
1527
|
+
}.freeze
|
1659
1528
|
|
1660
|
-
# A
|
1661
|
-
|
1529
|
+
# A hash mapping langauge set string constants to their RTF counterparts.
|
1530
|
+
# @return [Hash<String, Integer>] the RTF langauge setting dictionary.
|
1531
|
+
LS_DICTIONARY = {
|
1532
|
+
"AFRIKAANS" => 1078,
|
1533
|
+
"ARABIC" => 1025,
|
1534
|
+
"CATALAN" => 1027,
|
1535
|
+
"CHINESE_TRADITIONAL" => 1028,
|
1536
|
+
"CHINESE_SIMPLIFIED" => 2052,
|
1537
|
+
"CZECH" => 1029,
|
1538
|
+
"DANISH" => 1030,
|
1539
|
+
"DUTCH" => 1043,
|
1540
|
+
"DUTCH_BELGIAN" => 2067,
|
1541
|
+
"ENGLISH_UK" => 2057,
|
1542
|
+
"ENGLISH_US" => 1033,
|
1543
|
+
"FINNISH" => 1035,
|
1544
|
+
"FRENCH" => 1036,
|
1545
|
+
"FRENCH_BELGIAN" => 2060,
|
1546
|
+
"FRENCH_CANADIAN" => 3084,
|
1547
|
+
"FRENCH_SWISS" => 4108,
|
1548
|
+
"GERMAN" => 1031,
|
1549
|
+
"GERMAN_SWISS" => 2055,
|
1550
|
+
"GREEK" => 1032,
|
1551
|
+
"HEBREW" => 1037,
|
1552
|
+
"HUNGARIAN" => 1038,
|
1553
|
+
"ICELANDIC" => 1039,
|
1554
|
+
"INDONESIAN" => 1057,
|
1555
|
+
"ITALIAN" => 1040,
|
1556
|
+
"JAPANESE" => 1041,
|
1557
|
+
"KOREAN" => 1042,
|
1558
|
+
"NORWEGIAN_BOKMAL" => 1044,
|
1559
|
+
"NORWEGIAN_NYNORSK" => 2068,
|
1560
|
+
"POLISH" => 1045,
|
1561
|
+
"PORTUGUESE" => 2070,
|
1562
|
+
"POTUGUESE_BRAZILIAN" => 1046,
|
1563
|
+
"ROMANIAN" => 1048,
|
1564
|
+
"RUSSIAN" => 1049,
|
1565
|
+
"SERBO_CROATIAN_CYRILLIC" => 2074,
|
1566
|
+
"SERBO_CROATIAN_LATIN" => 1050,
|
1567
|
+
"SLOVAK" => 1051,
|
1568
|
+
"SPANISH_CASTILLIAN" => 1034,
|
1569
|
+
"SPANISH_MEXICAN" => 2058,
|
1570
|
+
"SWAHILI" => 1089,
|
1571
|
+
"SWEDISH" => 1053,
|
1572
|
+
"THAI" => 1054,
|
1573
|
+
"TURKISH" => 1055,
|
1574
|
+
"UNKNOWN" => 1024,
|
1575
|
+
"VIETNAMESE" => 1066
|
1576
|
+
}.freeze
|
1662
1577
|
|
1663
1578
|
# Attribute accessor.
|
1664
1579
|
attr_reader :fonts, :lists, :colours, :information, :character_set,
|
@@ -1668,35 +1583,25 @@ module RRTF
|
|
1668
1583
|
attr_writer :character_set, :language, :stylesheet
|
1669
1584
|
|
1670
1585
|
|
1671
|
-
#
|
1586
|
+
# Represents an entire RTF document.
|
1587
|
+
# @note The "suppress_system_styles" option is ignored by most RTF platforms including Word and LibreOffice.
|
1588
|
+
# @see DocumentStyle#initialize DocumentStyle#initialize for available document style options.
|
1589
|
+
# @see Stylesheet#add_style Stylesheet#initialize for available stylesheet options.
|
1672
1590
|
#
|
1673
|
-
#
|
1674
|
-
# options
|
1675
|
-
#
|
1676
|
-
#
|
1677
|
-
#
|
1678
|
-
#
|
1679
|
-
#
|
1680
|
-
# the style settings to be applied to the document.
|
1681
|
-
# DEFAULT DocumentStyle object with default settings.
|
1682
|
-
# character_set:: The character set to be applied to the document.
|
1683
|
-
# DEFAULT Document::CS_ANSI.
|
1684
|
-
# language:: The language setting to be applied to document.
|
1685
|
-
# DEFAULT Document::LC_ENGLISH_UK.
|
1686
|
-
# suppress_system_styles:: A Boolean indicating whether or not to add
|
1687
|
-
# the \noqfpromote control word, which indicates
|
1688
|
-
# "quick" or default styles should be suppressed.
|
1689
|
-
# DEFAULT false.
|
1690
|
-
# stylesheet:: A Stylesheet object OR hashmap array encapsulating
|
1691
|
-
# the styles to make available throughout the document.
|
1692
|
-
# DEFAULT nil.
|
1591
|
+
# @param [Hash<String, Object>] options the options to use in creating the document.
|
1592
|
+
# @option options [String, Font] "default_font" ("SWISS:Helvetica") a font object OR string encapsulating the default font to be used by the document (see {Font.from_string} for string format).
|
1593
|
+
# @option options [String] "character_set" ("ANSI") the character set to be applied to the document (see {CS_DICTIONARY} for valid values).
|
1594
|
+
# @option options [String] "language" ("ENGLISH_US") the language setting to be applied to the document (see {LS_DICTIONARY} for valid values).
|
1595
|
+
# @option options [Boolean] "suppress_system_styles" (false) whether or not to suppress styles provided in the host platform (adds the \noqfpromote control word before stylesheet definition).
|
1596
|
+
# @option options [DocumentStyle] "document_style" (DocumentStyle.new) a DocumentStyle object OR options hash encapsulating the style settings to be applied to the document.
|
1597
|
+
# @option options [Array, Hash, Stylesheet] "stylesheet" (nil) a Stylesheet object OR array of style hashes OR hash of stylesheet options with which to use as or construct the stylesheet for the document.
|
1693
1598
|
def initialize(options = {})
|
1694
1599
|
# load default options
|
1695
1600
|
options = {
|
1696
1601
|
"default_font" => "SWISS:Helvetica",
|
1697
1602
|
"document_style" => DocumentStyle.new,
|
1698
|
-
"character_set" =>
|
1699
|
-
"language" =>
|
1603
|
+
"character_set" => "ANSI",
|
1604
|
+
"language" => "ENGLISH_US",
|
1700
1605
|
"suppress_system_styles" => false,
|
1701
1606
|
"stylesheet" => nil
|
1702
1607
|
}.merge(options)
|
@@ -1723,13 +1628,27 @@ module RRTF
|
|
1723
1628
|
RTFError.fire("Unreconized document style format #{font.class.to_s}")
|
1724
1629
|
end # case
|
1725
1630
|
|
1631
|
+
# parse character set
|
1632
|
+
cs_string = options.delete("character_set")
|
1633
|
+
cs_val = CS_DICTIONARY[cs_string]
|
1634
|
+
if cs_val.nil?
|
1635
|
+
RTFError.fire("Unreconized character set '#{cs_string}'.")
|
1636
|
+
end # if
|
1637
|
+
|
1638
|
+
# parse language setting
|
1639
|
+
ls_string = options.delete("language")
|
1640
|
+
ls_val = LS_DICTIONARY[ls_string]
|
1641
|
+
if ls_val.nil?
|
1642
|
+
RTFError.fire("Unreconized language '#{ls_string}'.")
|
1643
|
+
end # if
|
1644
|
+
|
1726
1645
|
@fonts = FontTable.new(font)
|
1727
1646
|
@lists = ListTable.new
|
1728
1647
|
@default_font = 0
|
1729
1648
|
@colours = ColourTable.new
|
1730
1649
|
@information = Information.new
|
1731
|
-
@character_set =
|
1732
|
-
@language =
|
1650
|
+
@character_set = cs_val
|
1651
|
+
@language = ls_val
|
1733
1652
|
@style = style
|
1734
1653
|
@headers = [nil, nil, nil, nil]
|
1735
1654
|
@footers = [nil, nil, nil, nil]
|
@@ -7,9 +7,9 @@ module RRTF
|
|
7
7
|
|
8
8
|
# This is the constructor for the CharacterStyle class.
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
10
|
+
# @param [Hash] options the character style options.
|
11
|
+
# @option options (see Style#initialize)
|
12
|
+
# @option options (see CharacterFormatting#initialize_character_formatting)
|
13
13
|
def initialize(options = {})
|
14
14
|
super(options)
|
15
15
|
initialize_character_formatting(options)
|
@@ -45,6 +45,7 @@ module RRTF
|
|
45
45
|
rtf << "\\snext#{@next_style_handle}#{suffix}" unless @next_style_handle.nil?
|
46
46
|
rtf << "\\sqformat#{suffix}" if @primary
|
47
47
|
rtf << "\\spriority#{@priority}#{suffix}" unless @priority.nil?
|
48
|
+
rtf << "\\shidden#{suffix}" if @hidden
|
48
49
|
rtf << "#{name_prefix}#{name};}"
|
49
50
|
|
50
51
|
rtf.string
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
|
3
|
-
# Encapsulates all character formatting methods shared between style types
|
3
|
+
# Encapsulates all character formatting methods shared between style types.
|
4
|
+
# @author Wesley Hileman
|
4
5
|
module RRTF::CharacterFormatting
|
5
6
|
CHARACTER_ATTRIBUTES = {
|
6
7
|
# toggable attributes
|
@@ -72,7 +73,7 @@ module RRTF::CharacterFormatting
|
|
72
73
|
"default" => nil,
|
73
74
|
"to_rtf" => lambda{ |value, document| (value ? '\outl' : '\outl0') unless value.nil? }
|
74
75
|
},
|
75
|
-
"
|
76
|
+
"text_hidden" => {
|
76
77
|
"default" => nil,
|
77
78
|
"to_rtf" => lambda{ |value, document| (value ? '\v' : '\v0') unless value.nil? }
|
78
79
|
},
|
@@ -87,29 +88,29 @@ module RRTF::CharacterFormatting
|
|
87
88
|
},
|
88
89
|
"foreground_color" => {
|
89
90
|
"default" => nil,
|
90
|
-
"from_user" => lambda{ |value| RRTF::Colour.from_string(value) },
|
91
|
+
"from_user" => lambda{ |value| value.is_a?(RRTF::Colour) ? value : RRTF::Colour.from_string(value) },
|
91
92
|
"to_rtf" => lambda{ |value, document| "\\cf#{document.colours.index(value)}" unless value.nil? }
|
92
93
|
},
|
93
94
|
"background_color" => {
|
94
95
|
"default" => nil,
|
95
|
-
"from_user" => lambda{ |value| RRTF::Colour.from_string(value) },
|
96
|
+
"from_user" => lambda{ |value| value.is_a?(RRTF::Colour) ? value : RRTF::Colour.from_string(value) },
|
96
97
|
"to_rtf" => lambda{ |value, document| "\\cb#{document.colours.index(value)}" unless value.nil? }
|
97
98
|
},
|
98
99
|
"underline_color" => {
|
99
100
|
"default" => nil,
|
100
|
-
"from_user" => lambda{ |value| RRTF::Colour.from_string(value) },
|
101
|
+
"from_user" => lambda{ |value| value.is_a?(RRTF::Colour) ? value : RRTF::Colour.from_string(value) },
|
101
102
|
"to_rtf" => lambda{ |value, document| "\\ulc#{document.colours.index(value)}" unless value.nil? }
|
102
103
|
},
|
103
104
|
"font" => {
|
104
105
|
"default" => nil,
|
105
|
-
"from_user" => lambda{ |value| RRTF::Font.from_string(value) },
|
106
|
+
"from_user" => lambda{ |value| value.is_a?(RRTF::Font) ? value : RRTF::Font.from_string(value) },
|
106
107
|
"to_rtf" => lambda{ |value, document| "\\f#{document.fonts.index(value)}" unless value.nil? }
|
107
108
|
},
|
108
109
|
"font_size" => {
|
109
110
|
"default" => nil,
|
110
111
|
"to_rtf" => lambda{ |value, document| "\\fs#{value}" unless value.nil? }
|
111
112
|
}
|
112
|
-
}
|
113
|
+
}.freeze
|
113
114
|
|
114
115
|
def self.included(base)
|
115
116
|
# define accessors in base for paragraph attributes
|
@@ -120,6 +121,27 @@ module RRTF::CharacterFormatting
|
|
120
121
|
end # class_eval
|
121
122
|
end
|
122
123
|
|
124
|
+
# Initializes character formatting attributes.
|
125
|
+
#
|
126
|
+
# @param [Hash] options the character formatting options.
|
127
|
+
# @option options [Boolean] "bold" (nil) enable or disable bold (nil to remain same).
|
128
|
+
# @option options [Boolean] "italic" (nil) enable or disable italic (nil to remain same).
|
129
|
+
# @option options [Boolean, String] "underline" (nil) enable or disable underline (nil to remain same); can also be a string (see {CharacterFormatting::CHARACTER_ATTRIBUTES}).
|
130
|
+
# @option options [Boolean] "uppercase" (nil) enable or disable all caps (nil to remain same).
|
131
|
+
# @option options [Boolean] "superscript" (nil) enable or disable superscript (nil to remain same).
|
132
|
+
# @option options [Boolean] "subscript" (nil) enable or disable subscript (nil to remain same).
|
133
|
+
# @option options [Boolean] "strike" (nil) enable or disable single line-through (nil to remain same).
|
134
|
+
# @option options [Boolean] "emboss" (nil) enable or disable emboss (nil to remain same).
|
135
|
+
# @option options [Boolean] "imprint" (nil) enable or disable imprint (nil to remain same).
|
136
|
+
# @option options [Boolean] "outline" (nil) enable or disable outline (nil to remain same).
|
137
|
+
# @option options [Boolean] "text_hidden" (nil) enable or disable hidden (nil to remain same).
|
138
|
+
# @option options [Boolean, Integer] "kerning" (nil) enable or disable kerning (nil to remain same); to enable specify the font size in half-points above which kerining will be applied.
|
139
|
+
# @option options [Integer] "character_spacing_offset" (nil) quarter points by which to expand or compress character spacing (negative for compress).
|
140
|
+
# @option options [String, Colour] "foreground_color" (nil) colour to apply to the foreground (text); see {Colour.from_string} for string format.
|
141
|
+
# @option options [String, Colour] "background_color" (nil) colour to apply to the background (highlight); see {Colour.from_string} for string format.
|
142
|
+
# @option options [String, Colour] "underline_color" (nil) colour to apply to the underline; see {Colour.from_string} for string format.
|
143
|
+
# @option options [String, Font] "font" (nil) font to apply to text; see {Font.from_string} for string format.
|
144
|
+
# @option options [Integer] "font_size" (nil) font size in half-points.
|
123
145
|
def initialize_character_formatting(options = {})
|
124
146
|
# load default attribute values
|
125
147
|
CHARACTER_ATTRIBUTES.each do |key, options|
|
@@ -159,14 +181,18 @@ module RRTF::CharacterFormatting
|
|
159
181
|
|
160
182
|
# accumulate RTF representations of attributes
|
161
183
|
CHARACTER_ATTRIBUTES.each do |key, options|
|
162
|
-
|
184
|
+
if options.has_key?("to_rtf")
|
185
|
+
rtf = options["to_rtf"].call(send(key), document)
|
186
|
+
text << rtf unless rtf.nil?
|
187
|
+
end # if
|
163
188
|
end # each
|
164
189
|
|
165
190
|
text.string
|
166
191
|
end
|
167
192
|
end # module CharacterFormatting
|
168
193
|
|
169
|
-
# Encapsulates all paragraph formatting methods shared between style types
|
194
|
+
# Encapsulates all paragraph formatting methods shared between style types.
|
195
|
+
# @author Wesley Hileman
|
170
196
|
module RRTF::ParagraphFormatting
|
171
197
|
PARAGRAPH_ATTRIBUTES = {
|
172
198
|
"justification" => {
|
@@ -228,7 +254,7 @@ module RRTF::ParagraphFormatting
|
|
228
254
|
},
|
229
255
|
"to_rtf" => lambda{ |value, document| "\\#{value}par" unless value.nil? }
|
230
256
|
}
|
231
|
-
}
|
257
|
+
}.freeze
|
232
258
|
|
233
259
|
def self.included(base)
|
234
260
|
# define accessors in base for paragraph attributes
|
@@ -239,6 +265,21 @@ module RRTF::ParagraphFormatting
|
|
239
265
|
end # class_eval
|
240
266
|
end
|
241
267
|
|
268
|
+
# Initializes paragraph formatting attributes.
|
269
|
+
#
|
270
|
+
# @param [Hash] options the paragraph formatting options.
|
271
|
+
# @option options [String] "justification" ('LEFT') the paragraph justification ('LEFT', 'CENTER'/'CENTRE', 'RIGHT', or 'FULL').
|
272
|
+
# @option options [Integer] "left_indent" (nil) the left indent of the paragraph (twentieth points).
|
273
|
+
# @option options [Integer] "right_indent" (nil) the right indent of the paragraph (twentieth points).
|
274
|
+
# @option options [Integer] "first_line_indent" (nil) the first line indent of the paragraph (twentieth points).
|
275
|
+
# @option options [Integer] "space_before" (nil) the space before the paragraph (twentieth points).
|
276
|
+
# @option options [Integer] "space_after" (nil) the space after the paragraph (twentieth points).
|
277
|
+
# @option options [Integer] "line_spacing" (nil) the line spacing in the paragraph (twentieth points).
|
278
|
+
# @option options [Boolean] "widow_orphan_ctl" (nil) enable or disable widow-and-orphan control.
|
279
|
+
# @option options [Boolean] "no_break" (nil) when true, tries to keep the paragraph on the same page (i.e. without breaking).
|
280
|
+
# @option options [Boolean] "no_break_with_next" (nil) when true, tries to keep the paragraph with the next paragraph on the same page (i.e. without breaking).
|
281
|
+
# @option options [Boolean] "hyphenate" (nil) enable or disable hyphenation for the paragraph.
|
282
|
+
# @option options [String] "paragraph_flow" ('LEFT_TO_RIGHT') the text flow direction in the paragraph ('LEFT_TO_RIGHT' or 'RIGHT_TO_LEFT').
|
242
283
|
def initialize_paragraph_formatting(options = {})
|
243
284
|
# load default attribute values
|
244
285
|
PARAGRAPH_ATTRIBUTES.each do |key, options|
|
@@ -268,7 +309,10 @@ module RRTF::ParagraphFormatting
|
|
268
309
|
|
269
310
|
# accumulate RTF representations of paragraph attributes
|
270
311
|
PARAGRAPH_ATTRIBUTES.each do |key, options|
|
271
|
-
|
312
|
+
if options.has_key?("to_rtf")
|
313
|
+
rtf = options["to_rtf"].call(send(key), document)
|
314
|
+
text << rtf unless rtf.nil?
|
315
|
+
end # if
|
272
316
|
end # each
|
273
317
|
|
274
318
|
text.string
|