Skip to content

Commit

Permalink
some reverts; current stable; add tidy file
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Dec 23, 2023
1 parent 63284d9 commit a3f42cd
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 7 deletions.
99 changes: 99 additions & 0 deletions experiments/.html-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
accessibility-check: 0 (Tidy Classic)
add-meta-charset: no
add-xml-decl: no
add-xml-space: no
alt-text:
anchor-as-name: yes
ascii-chars: no
assume-xml-procins: no
bare: no
break-before-br: no
char-encoding: utf8
clean: no
coerce-endtags: no
css-prefix: c
custom-tags: no
decorate-inferred-ul: no
doctype: html5
drop-empty-elements: no
drop-empty-paras: no
drop-proprietary-attributes: no
enclose-block-text: no
enclose-text: no
error-file:
escape-cdata: no
escape-scripts: yes
fix-backslash: yes
fix-bad-comments: auto
fix-style-tags: yes
fix-uri: no
force-output: yes
gdoc: no
gnu-emacs: no
hide-comments: no
indent: auto
indent-attributes: no
indent-cdata: no
indent-spaces: 2
indent-with-tabs: no
input-encoding: utf8
input-xml: no
join-classes: no
join-styles: yes
keep-tabs: no
keep-time: no
literal-attributes: no
logical-emphasis: no
lower-literals: yes
markup: yes
merge-divs: auto
merge-emphasis: yes
merge-spans: auto
mute:
mute-id: no
ncr: yes
new-blocklevel-tags: x-odr-s
new-empty-tags:
new-inline-tags:
new-pre-tags:
newline: LF
numeric-entities: no
omit-optional-tags: no
output-bom: auto
output-encoding: utf8
output-file:
output-html: no
output-xhtml: no
output-xml: no
preserve-entities: yes
priority-attributes:
punctuation-wrap: no
quiet: no
quote-ampersand: yes
quote-marks: no
quote-nbsp: yes
repeated-attributes: keep-last
replace-color: no
show-body-only: no
show-errors: 6
show-info: yes
show-meta-change: no
show-warnings: yes
skip-nested: yes
sort-attributes: alpha
strict-tags-attributes: no
tab-size: 4
tidy-mark: no
uppercase-attributes: no
uppercase-tags: no
vertical-space: no
warn-proprietary-attributes: yes
word-2000: no
wrap: 0
wrap-asp: no
wrap-attributes: no
wrap-jste: no
wrap-php: no
wrap-script-literals: no
wrap-sections: no
write-back: no
9 changes: 4 additions & 5 deletions src/odr/internal/html/document_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,10 @@ void html::translate_line_break(Element element, std::ostream &out,
void html::translate_paragraph(Element element, std::ostream &out,
const HtmlConfig &config) {
auto paragraph = element.paragraph();
auto text_style_attribute =
optional_style_attribute(translate_text_style(paragraph.text_style()));

out << "<x-p";
out << optional_style_attribute(translate_paragraph_style(paragraph.style()));
out << optional_style_attribute("display:block;" +
translate_paragraph_style(paragraph.style()));
out << ">";
translate_children(paragraph.children(), out, config);
if (paragraph.first_child()) {
Expand All @@ -265,6 +264,8 @@ void html::translate_paragraph(Element element, std::ostream &out,

// TODO example `style-missing+image-1.odt` first paragraph has no height
} else {
auto text_style_attribute =
optional_style_attribute(translate_text_style(paragraph.text_style()));
out << "<x-s" << text_style_attribute << "></x-s>";
}
out << "<wbr>";
Expand Down Expand Up @@ -398,12 +399,10 @@ void html::translate_frame(Element element, std::ostream &out,
auto style = frame.style();

out << "<div";

out << optional_style_attribute(translate_frame_properties(frame) +
translate_drawing_style(style));
out << ">";
translate_children(frame.children(), out, config);

out << "</div>";
}

Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/odf/odf_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ odf::parse_any_element_tree(Document &document, pugi::xml_node node) {
{"draw:circle", parse_element_tree<Circle>},
{"draw:custom-shape", parse_element_tree<CustomShape>},
{"draw:text-box", parse_element_tree<Group>},
{"draw:g", parse_element_tree<Group>},
{"draw:g", parse_element_tree<Frame>},
{"draw:a", parse_element_tree<Link>},
{"style:master-page", parse_element_tree<MasterPage>}};

Expand Down
18 changes: 17 additions & 1 deletion src/odr/internal/odf/odf_spreadsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ void Sheet::init_dimensions_(TableDimensions dimensions) {
m_index.dimensions = dimensions;
}

void Sheet::append_shape_(Element *shape) {
shape->m_previous_sibling = m_last_shape;
shape->m_parent = this;
if (m_last_shape == nullptr) {
m_first_shape = shape;
} else {
m_last_shape->m_next_sibling = shape;
}
m_last_shape = shape;
}

} // namespace odr::internal::odf

namespace odr::internal {
Expand Down Expand Up @@ -331,7 +342,12 @@ odf::parse_element_tree<odf::Sheet>(Document &document, pugi::xml_node node) {

sheet.init_dimensions_(dimensions);

// TODO shapes
for (auto shape_node : node.child("table:shapes").children()) {
auto [shape, _] = parse_any_element_tree(document, shape_node);
if (shape != nullptr) {
sheet.append_shape_(shape);
}
}

return std::make_tuple(&sheet, node.next_sibling());
}
Expand Down
2 changes: 2 additions & 0 deletions src/odr/internal/odf/odf_spreadsheet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Sheet final : public Element, public abstract::Sheet {
void init_cell_element_(std::uint32_t column, std::uint32_t row,
SheetCell *element);
void init_dimensions_(TableDimensions dimensions);
void append_shape_(Element *shape);

common::ResolvedStyle cell_style_(const abstract::Document *,
std::uint32_t column,
Expand All @@ -97,6 +98,7 @@ class Sheet final : public Element, public abstract::Sheet {

std::unordered_map<common::TablePosition, SheetCell *> m_cells;
Element *m_first_shape{nullptr};
Element *m_last_shape{nullptr};
};

template <>
Expand Down

0 comments on commit a3f42cd

Please sign in to comment.