Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Dec 4, 2023
1 parent cfa29fb commit 9696cce
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 335 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ add_library(odr
"src/odr/internal/csv/csv_util.cpp"

"src/odr/internal/html/common.cpp"
"src/odr/internal/html/css_writer.cpp"
"src/odr/internal/html/document.cpp"
"src/odr/internal/html/document_style.cpp"
"src/odr/internal/html/document_element.cpp"
Expand Down
59 changes: 40 additions & 19 deletions src/odr/document_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <odr/style.hpp>

#include <odr/internal/abstract/document_element.hpp>
#include <odr/internal/abstract/sheet_element.hpp>

namespace odr {

Expand Down Expand Up @@ -181,21 +182,12 @@ TableDimensions Sheet::content(std::optional<TableDimensions> range) const {
return exists_() ? m_element->content(m_document, range) : TableDimensions();
}

TableColumn Sheet::column(std::uint32_t column) const {
return exists_()
? TableColumn(m_document, m_element->column(m_document, column))
: TableColumn();
}

TableRow Sheet::row(std::uint32_t row) const {
return exists_() ? TableRow(m_document, m_element->row(m_document, row))
: TableRow();
}

TableCell Sheet::cell(std::uint32_t column, std::uint32_t row) const {
return exists_()
? TableCell(m_document, m_element->cell(m_document, column, row))
: TableCell();
ElementRange Sheet::cell_elements(std::uint32_t column,
std::uint32_t row) const {
return exists_() ? ElementRange(ElementIterator(m_document,
m_element->first_cell_element(
m_document, column, row)))
: ElementRange();
}

ElementRange Sheet::shapes() const {
Expand All @@ -208,6 +200,35 @@ TableStyle Sheet::style() const {
return exists_() ? m_element->style(m_document) : TableStyle();
}

TableColumnStyle Sheet::column_style(std::uint32_t column) const {
return exists_() ? m_element->column_style(m_document, column)
: TableColumnStyle();
}

TableRowStyle Sheet::row_style(std::uint32_t row) const {
return exists_() ? m_element->row_style(m_document, row) : TableRowStyle();
}

TableCellStyle Sheet::cell_style(std::uint32_t column,
std::uint32_t row) const {
return exists_() ? m_element->cell_style(m_document, column, row)
: TableCellStyle();
}

bool Sheet::is_covered(std::uint32_t column, std::uint32_t row) const {
return exists_() ? m_element->is_covered(m_document, column, row) : false;
}

TableDimensions Sheet::span(std::uint32_t column, std::uint32_t row) const {
return exists_() ? m_element->span(m_document, column, row)
: TableDimensions();
}

ValueType Sheet::value_type(std::uint32_t column, std::uint32_t row) const {
return exists_() ? m_element->value_type(m_document, column, row)
: ValueType::unknown;
}

std::string Page::name() const {
return exists_() ? m_element->name(m_document) : "";
}
Expand Down Expand Up @@ -295,8 +316,8 @@ TableRowStyle TableRow::style() const {
return exists_() ? m_element->style(m_document) : TableRowStyle();
}

bool TableCell::covered() const {
return exists_() && m_element->covered(m_document);
bool TableCell::is_covered() const {
return exists_() && m_element->is_covered(m_document);
}

TableDimensions TableCell::span() const {
Expand Down Expand Up @@ -423,8 +444,8 @@ GraphicStyle CustomShape::style() const {
return exists_() ? m_element->style(m_document) : GraphicStyle();
}

bool Image::internal() const {
return exists_() && m_element->internal(m_document);
bool Image::is_internal() const {
return exists_() && m_element->is_internal(m_document);
}

std::optional<File> Image::file() const {
Expand Down
21 changes: 15 additions & 6 deletions src/odr/document_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ enum class AnchorType {
};

enum class ValueType {
unknown,
string,
float_number,
};
Expand Down Expand Up @@ -260,13 +261,21 @@ class Sheet final : public TypedElement<internal::abstract::Sheet> {
[[nodiscard]] TableDimensions
content(std::optional<TableDimensions> range) const;

[[nodiscard]] TableColumn column(std::uint32_t column) const;
[[nodiscard]] TableRow row(std::uint32_t row) const;
[[nodiscard]] TableCell cell(std::uint32_t column, std::uint32_t row) const;

[[nodiscard]] ElementRange cell_elements(std::uint32_t column,
std::uint32_t row) const;
[[nodiscard]] ElementRange shapes() const;

[[nodiscard]] TableStyle style() const;
[[nodiscard]] TableColumnStyle column_style(std::uint32_t column) const;
[[nodiscard]] TableRowStyle row_style(std::uint32_t row) const;
[[nodiscard]] TableCellStyle cell_style(std::uint32_t column,
std::uint32_t row) const;

[[nodiscard]] bool is_covered(std::uint32_t column, std::uint32_t row) const;
[[nodiscard]] TableDimensions span(std::uint32_t column,
std::uint32_t row) const;
[[nodiscard]] ValueType value_type(std::uint32_t column,
std::uint32_t row) const;
};

class Page final : public TypedElement<internal::abstract::Page> {
Expand Down Expand Up @@ -373,7 +382,7 @@ class TableCell final : public TypedElement<internal::abstract::TableCell> {
[[nodiscard]] TableColumn column() const;
[[nodiscard]] TableRow row() const;

[[nodiscard]] bool covered() const;
[[nodiscard]] bool is_covered() const;
[[nodiscard]] TableDimensions span() const;
[[nodiscard]] ValueType value_type() const;

Expand Down Expand Up @@ -446,7 +455,7 @@ class Image final : public TypedElement<internal::abstract::Image> {
public:
using TypedElement::TypedElement;

[[nodiscard]] bool internal() const;
[[nodiscard]] bool is_internal() const;
[[nodiscard]] std::optional<odr::File> file() const;
[[nodiscard]] std::string href() const;
};
Expand Down
65 changes: 2 additions & 63 deletions src/odr/internal/abstract/document_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,6 @@ class Slide : public virtual Element {
[[nodiscard]] virtual std::string name(const Document *) const = 0;
};

class Sheet : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::sheet;
}

[[nodiscard]] virtual std::string name(const Document *) const = 0;

[[nodiscard]] virtual TableDimensions dimensions(const Document *) const = 0;
[[nodiscard]] virtual TableDimensions
content(const Document *, std::optional<TableDimensions> range) const = 0;

[[nodiscard]] virtual Element *column(const Document *,
std::uint32_t column) const = 0;
[[nodiscard]] virtual Element *row(const Document *,
std::uint32_t row) const = 0;
[[nodiscard]] virtual Element *cell(const Document *, std::uint32_t column,
std::uint32_t row) const = 0;

[[nodiscard]] virtual Element *first_shape(const Document *) const = 0;

[[nodiscard]] virtual TableStyle style(const Document *) const = 0;
};

class Page : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
Expand Down Expand Up @@ -218,7 +194,7 @@ class TableCell : public virtual Element {
return ElementType::table_cell;
}

[[nodiscard]] virtual bool covered(const Document *) const = 0;
[[nodiscard]] virtual bool is_covered(const Document *) const = 0;
[[nodiscard]] virtual TableDimensions span(const Document *) const = 0;
[[nodiscard]] virtual ValueType value_type(const Document *) const = 0;

Expand Down Expand Up @@ -310,49 +286,12 @@ class Image : public virtual Element {
return ElementType::image;
}

[[nodiscard]] virtual bool internal(const Document *) const = 0;
[[nodiscard]] virtual bool is_internal(const Document *) const = 0;
[[nodiscard]] virtual std::optional<odr::File>
file(const Document *) const = 0;
[[nodiscard]] virtual std::string href(const Document *) const = 0;
};

class SheetColumn : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::table_column;
}

[[nodiscard]] virtual TableColumnStyle style(const Document *,
std::uint32_t column) const = 0;
};

class SheetRow : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::table_row;
}

[[nodiscard]] virtual TableRowStyle style(const Document *) const = 0;
};

class SheetCell : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::table_cell;
}

[[nodiscard]] virtual bool covered(const Document *, std::uint32_t column,
std::uint32_t row) const = 0;
[[nodiscard]] virtual TableDimensions
span(const Document *, std::uint32_t column, std::uint32_t row) const = 0;
[[nodiscard]] virtual ValueType value_type(const Document *,
std::uint32_t column,
std::uint32_t row) const = 0;

[[nodiscard]] virtual TableCellStyle
style(const Document *, std::uint32_t column, std::uint32_t row) const = 0;
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_DOCUMENT_ELEMENT_H
76 changes: 76 additions & 0 deletions src/odr/internal/abstract/sheet_element.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#ifndef ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_H
#define ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_H

#include <odr/internal/abstract/document_element.hpp>

namespace odr::internal::abstract {
class SheetColumn;
class SheetRow;
class SheetCell;

class Sheet : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::sheet;
}

[[nodiscard]] virtual std::string name(const Document *) const = 0;

[[nodiscard]] virtual TableDimensions dimensions(const Document *) const = 0;
[[nodiscard]] virtual TableDimensions
content(const Document *, std::optional<TableDimensions> range) const = 0;

[[nodiscard]] virtual SheetColumn *column(const Document *,
std::uint32_t column) const = 0;
[[nodiscard]] virtual SheetRow *row(const Document *,
std::uint32_t row) const = 0;
[[nodiscard]] virtual SheetCell *cell(const Document *, std::uint32_t column,
std::uint32_t row) const = 0;

[[nodiscard]] virtual Element *first_shape(const Document *) const = 0;
};

class SheetColumn : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::table_column;
}

[[nodiscard]] virtual TableColumnStyle style(const Document *, const Sheet *,
std::uint32_t column) const = 0;
};

class SheetRow : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::table_row;
}

[[nodiscard]] virtual TableRowStyle style(const Document *, const Sheet *,
std::uint32_t row) const = 0;
};

class SheetCell : public virtual Element {
public:
[[nodiscard]] ElementType type(const Document *) const override {
return ElementType::table_cell;
}

[[nodiscard]] virtual bool is_covered(const Document *, const Sheet *,
std::uint32_t column,
std::uint32_t row) const = 0;
[[nodiscard]] virtual TableDimensions span(const Document *, const Sheet *,
std::uint32_t column,
std::uint32_t row) const = 0;
[[nodiscard]] virtual ValueType value_type(const Document *, const Sheet *,
std::uint32_t column,
std::uint32_t row) const = 0;

[[nodiscard]] virtual TableCellStyle style(const Document *, const Sheet *,
std::uint32_t column,
std::uint32_t row) const = 0;
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_H
4 changes: 0 additions & 4 deletions src/odr/internal/common/document_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class Table : public virtual Element, public abstract::Table {
Element *m_last_column{};
};

class Sheet : public virtual Element, public abstract::Sheet {
public:
};

} // namespace odr::internal::common

#endif // ODR_INTERNAL_COMMON_DOCUMENT_ELEMENT_H
3 changes: 0 additions & 3 deletions src/odr/internal/html/css_writer.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions src/odr/internal/html/css_writer.hpp

This file was deleted.

Loading

0 comments on commit 9696cce

Please sign in to comment.