Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make comments work in office for mac 2015 #382

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/axlsx/workbook/worksheet/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def to_xml_string(str = "")
str << '<text>'
unless author.to_s == ""
str << '<r><rPr><b/><color indexed="81"/></rPr>'
str << ("<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>")
str << ('<t>' << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>")
end
str << '<r>'
str << '<rPr><color indexed="81"/></rPr>'
str << ('<t>' << ::CGI.escapeHTML(text) << '</t></r></text>')
str << ('<t xml:space="preserve">' << ::CGI.escapeHTML(text) << '</t></r></text>')
str << '</comment>'
end

Expand All @@ -82,9 +82,9 @@ def initialize_vml_shape
pos = Axlsx::name_to_indices(ref)
@vml_shape = VmlShape.new(:row => pos[1], :column => pos[0], :visible => @visible) do |vml|
vml.left_column = vml.column
vml.right_column = vml.column + 2
vml.right_column = vml.column + 2
vml.top_row = vml.row
vml.bottom_row = vml.row + 4
vml.bottom_row = vml.row + 4
end
end
end
Expand Down
39 changes: 23 additions & 16 deletions lib/schema/sml.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
schemaLocation="shared-relationshipReference.xsd"/>
<xsd:import namespace="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"
schemaLocation="shared-commonSimpleTypes.xsd"/>
<xsd:import
<xsd:import
namespace="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
schemaLocation="dml-spreadsheetDrawing.xsd"/>
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>

<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
<xsd:complexType name="CT_AutoFilter">
<xsd:sequence>
<xsd:element name="filterColumn" minOccurs="0" maxOccurs="unbounded" type="CT_FilterColumn"/>
Expand Down Expand Up @@ -1799,7 +1799,7 @@
</xsd:sequence>
<xsd:attribute name="count" type="xsd:unsignedInt" use="optional"/>
<xsd:attribute name="uniqueCount" type="xsd:unsignedInt" use="optional"/>
<xsd:attribute ref="xml:space"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
<xsd:simpleType name="ST_PhoneticType">
<xsd:restriction base="xsd:string">
Expand Down Expand Up @@ -1827,7 +1827,7 @@
<xsd:complexType name="CT_RElt">
<xsd:sequence>
<xsd:element name="rPr" type="CT_RPrElt" minOccurs="0" maxOccurs="1"/>
<xsd:element name="t" type="s:ST_Xstring" minOccurs="1" maxOccurs="1"/>
<xsd:element name="t" type="CT_StringWithSpace" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CT_RPrElt">
Expand Down Expand Up @@ -1857,6 +1857,13 @@
<xsd:element name="phoneticPr" minOccurs="0" maxOccurs="1" type="CT_PhoneticPr"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CT_StringWithSpace">
<xsd:simpleContent>
<xsd:extension base="s:ST_Xstring">
<xsd:attribute ref="xml:space"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="CT_PhoneticPr">
<xsd:attribute name="fontId" type="ST_FontId" use="required"/>
<xsd:attribute name="type" type="ST_PhoneticType" use="optional" default="fullwidthKatakana"/>
Expand Down Expand Up @@ -2216,7 +2223,7 @@
<xsd:element name="tableParts" type="CT_TableParts" minOccurs="0" maxOccurs="1"/>
<xsd:element name="extLst" type="CT_ExtensionList" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute ref="xml:space"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
<xsd:complexType name="CT_SheetData">
<xsd:sequence>
Expand Down Expand Up @@ -3776,7 +3783,7 @@
<xsd:choice maxOccurs="unbounded">
<xsd:element name="name" type="CT_FontName" minOccurs="0" maxOccurs="1"/>
<xsd:element name="charset" type="CT_IntProperty" minOccurs="0" maxOccurs="1"/>
<xsd:element name="family" type="CT_FontFamily" minOccurs="0" maxOccurs="1"/>
<xsd:element name="family" type="CT_FontFamily" minOccurs="0" maxOccurs="1"/>
<xsd:element name="b" type="CT_BooleanProperty" minOccurs="0" maxOccurs="1"/>
<xsd:element name="i" type="CT_BooleanProperty" minOccurs="0" maxOccurs="1"/>
<xsd:element name="strike" type="CT_BooleanProperty" minOccurs="0" maxOccurs="1"/>
Expand All @@ -3791,15 +3798,15 @@
<xsd:element name="scheme" type="CT_FontScheme" minOccurs="0" maxOccurs="1"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="CT_FontFamily">
<xsd:attribute name="val" type="ST_FontFamily" use="required"/>
</xsd:complexType>
<xsd:simpleType name="ST_FontFamily">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="14"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="CT_FontFamily">
<xsd:attribute name="val" type="ST_FontFamily" use="required"/>
</xsd:complexType>
<xsd:simpleType name="ST_FontFamily">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="14"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:attributeGroup name="AG_AutoFormat">
<xsd:attribute name="autoFormatId" type="xsd:unsignedInt"/>
<xsd:attribute name="applyNumberFormats" type="xsd:boolean"/>
Expand Down
1 change: 1 addition & 0 deletions test/workbook/worksheet/tc_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_to_xml_string
assert_equal(doc.xpath("//comment[@authorId='#{@c1.author_index.to_s}']").size, 1)
assert_equal(doc.xpath("//t[text()='#{@c1.author}:\n']").size, 1)
assert_equal(doc.xpath("//t[text()='#{@c1.text}']").size, 1)
assert_equal(doc.xpath("//t[text()='#{@c1.text}'][@xml:space='preserve']").size, 1)
end

def test_comment_text_contain_author_and_text
Expand Down