diff --git a/R/01_fpstruct.R b/R/01_fpstruct.R index 72d7a457..a2f87694 100644 --- a/R/01_fpstruct.R +++ b/R/01_fpstruct.R @@ -1,7 +1,3 @@ -add_rows <- function(x, ...) { - UseMethod("add_rows") -} - # fpstruct ------ fpstruct <- function(nrow, keys, default) { @@ -45,7 +41,7 @@ get_fpstruct_elements <- function(x, i, j) { #' @importFrom utils head tail -add_rows.fpstruct <- function(x, nrows, first, default = x$default, ...) { +add_rows_fpstruct <- function(x, nrows, first, default = x$default, ...) { if (nrow(x$data) < 1) { new <- matrix(rep(default, x$ncol * nrows), ncol = x$ncol) } else if (first) { @@ -122,9 +118,9 @@ print.text_struct <- function(x, ...) { cat("a text_struct with ", dims[1], " rows and ", dims[2], " columns", sep = "") } -add_rows.text_struct <- function(x, nrows, first, ...) { +add_rows_to_struct <- function(x, nrows, first, ...) { for (i in seq_len(length(x))) { - x[[i]] <- add_rows(x[[i]], nrows, first = first) + x[[i]] <- add_rows_fpstruct(x[[i]], nrows, first = first) } x } @@ -184,15 +180,6 @@ print.par_struct <- function(x, ...) { cat("a par_struct with ", dims[1], " rows and ", dims[2], " columns", sep = "") } - -add_rows.par_struct <- function(x, nrows, first, ...) { - for (i in seq_len(length(x))) { - x[[i]] <- add_rows(x[[i]], nrows, first = first) - } - x -} - - `[<-.par_struct` <- function(x, i, j, property, value) { if (inherits(value, "fp_par")) { value <- cast_borders(value) @@ -264,13 +251,6 @@ cell_struct <- function(nrow, keys, x } -add_rows.cell_struct <- function(x, nrows, first, ...) { - for (i in seq_len(length(x))) { - x[[i]] <- add_rows(x[[i]], nrows, first = first) - } - x -} - `[<-.cell_struct` <- function(x, i, j, property, value) { if (inherits(value, "fp_cell")) { value <- cast_borders(value) @@ -338,7 +318,7 @@ add_rows_to_chunkset_struct <- function(x, nrows, first, data, ...) { names_ <- names(data) stopifnot(!is.null(names_)) - x <- add_rows.fpstruct(x, nrows, first = first, default = as_paragraph(as_chunk(""))) + x <- add_rows_fpstruct(x, nrows, first = first, default = as_paragraph(as_chunk(""))) if (first) { id <- seq_len(nrows) } else { diff --git a/R/augment_rows.R b/R/augment_rows.R index 3a0b8792..15dfff41 100644 --- a/R/augment_rows.R +++ b/R/augment_rows.R @@ -271,9 +271,9 @@ add_rows_to_tabpart <- function(x, rows, first = FALSE) { ncol <- length(x$col_keys) nrow <- nrow(rows) - x$styles$cells <- add_rows(x$styles$cells, nrows = nrow, first = first) - x$styles$pars <- add_rows(x$styles$pars, nrows = nrow, first = first) - x$styles$text <- add_rows(x$styles$text, nrows = nrow, first = first) + x$styles$cells <- add_rows_to_struct(x$styles$cells, nrows = nrow, first = first) + x$styles$pars <- add_rows_to_struct(x$styles$pars, nrows = nrow, first = first) + x$styles$text <- add_rows_to_struct(x$styles$text, nrows = nrow, first = first) x$content <- add_rows_to_chunkset_struct(x$content, nrows = nrow, first = first, rows) span_new <- matrix(1, ncol = ncol, nrow = nrow)