diff --git a/R/add_to_body.R b/R/add_to_body.R index 2e301a8..1b68ccc 100644 --- a/R/add_to_body.R +++ b/R/add_to_body.R @@ -117,7 +117,7 @@ add_text_to_body <- function(docx, .null = NULL, .envir = parent.frame(), ...) { - rlang::check_required(value) + check_required(value) value <- glue::glue(value, .na = .na, .null = .null, .envir = .envir) add_to_body(docx, value = value, style = style, pos = pos, ...) } @@ -131,7 +131,7 @@ add_xml_to_body <- function(docx, pos = "after", ..., call = caller_env()) { - rlang::check_required(str, call = call) + check_required(str, call = call) add_to_body(docx, str = str, pos = pos, ..., call = call) } @@ -186,8 +186,8 @@ add_gt_to_body <- function(docx, tablecontainer = TRUE, ..., call = caller_env()) { - rlang::check_required(gt_object, call = call) - rlang::check_installed("gt", call = call) + check_required(gt_object, call = call) + check_installed("gt", call = call) str <- gt::as_word( gt_object, @@ -199,6 +199,9 @@ add_gt_to_body <- function(docx, ) if (!tablecontainer) { + # FIXME: I thought this worked prior to incorporating the gto code but it is + # not working any more. Check and possibly remove the tablecontainer + # parameter if I can't get it working. docx <- add_xml_to_body( docx, str = str, @@ -250,7 +253,7 @@ add_gg_to_body <- function(docx, style = "Normal", pos = "after", ...) { - rlang::check_required(value) + check_required(value) docx <- add_to_body(docx, value = value, style = style, pos = pos, ...) if (!is.null(caption) && !is.null(value[["labels"]][[caption]])) { @@ -295,19 +298,19 @@ add_value_with_keys <- function(docx, ) arg <- "keyword" - rlang::check_required(value) - .f <- rlang::as_function(.f) + check_required(value) + .f <- as_function(.f) value <- set_vec_value_names(value, arg = arg, ...) - params <- rlang::list2(...) + params <- list2(...) - if (rlang::has_name(params, arg)) { + if (has_name(params, arg)) { params[[arg]] <- NULL } for (i in seq_along(value)) { docx <- - rlang::exec( + exec( .f, docx, value = value[[i]], @@ -334,19 +337,19 @@ add_str_with_keys <- function(docx, ) arg <- "keyword" - rlang::check_required(str) - .f <- rlang::as_function(.f) + check_required(str) + .f <- as_function(.f) str <- set_vec_value_names(str, arg = arg, ...) - params <- rlang::list2(...) + params <- list2(...) - if (rlang::has_name(params, arg)) { + if (has_name(params, arg)) { params[[arg]] <- NULL } for (i in seq_along(str)) { docx <- - rlang::exec( + exec( .f, docx, str = str[[i]], @@ -368,12 +371,12 @@ add_str_with_keys <- function(docx, #' @importFrom rlang is_named list2 set_names #' @importFrom cli cli_abort set_vec_value_names <- function(value, nm = NULL, arg = "keyword", ...) { - if (rlang::is_named(value)) { + if (is_named(value)) { return(value) } if (is.null(nm)) { - params <- rlang::list2(...) + params <- list2(...) if (is.null(params[[arg]]) || (length(params[[arg]]) != length(value))) { cli_abort( "{.arg value} must {.arg {arg}} must be be the same length @@ -383,5 +386,5 @@ set_vec_value_names <- function(value, nm = NULL, arg = "keyword", ...) { nm <- params[[arg]] } - rlang::set_names(value, nm) + set_names(value, nm) } diff --git a/R/convert_docx.R b/R/convert_docx.R index 88fdb65..31658ec 100644 --- a/R/convert_docx.R +++ b/R/convert_docx.R @@ -53,7 +53,7 @@ convert_docx <- function(docx = NULL, overwrite = TRUE, quiet = TRUE, ...) { - rlang::check_installed("rmarkdown") + check_installed("rmarkdown") if (is_officer(docx, "rdocx")) { if (!is.null(input) && is_true(quiet)) { @@ -72,7 +72,6 @@ convert_docx <- function(docx = NULL, path <- path %||% getwd() } else if (is.null(input)) { - rlang::check_required(docx) check_docx_fileext(docx) input <- docx } diff --git a/R/officer_media.R b/R/officer_media.R index 4fc9690..65b2397 100644 --- a/R/officer_media.R +++ b/R/officer_media.R @@ -102,7 +102,7 @@ officer_media <- function(filename = NULL, if (isTRUE(list)) { cli::cli_bullets( - rlang::set_names( + set_names( basename(media_files), rep("*", length(media_files)) ) diff --git a/R/officer_summary.R b/R/officer_summary.R index 3bcc620..d32fb1c 100644 --- a/R/officer_summary.R +++ b/R/officer_summary.R @@ -194,8 +194,8 @@ is_officer_summary <- function(x, nm_check <- TRUE if (identical(summary_type, "doc")) { - nm_check <- any(rlang::has_name(x, c(docx_nm, pptx_nm))) + nm_check <- any(has_name(x, c(docx_nm, pptx_nm))) } - all(rlang::has_name(x, nm)) && nm_check + all(has_name(x, nm)) && nm_check } diff --git a/R/officer_tables.R b/R/officer_tables.R index c520c51..f8b669c 100644 --- a/R/officer_tables.R +++ b/R/officer_tables.R @@ -111,7 +111,7 @@ officer_tables <- function(x, return(do.call("rbind", tables)) } - rlang::set_names(tables, nm %||% glue("doc_index_{index}")) + set_names(tables, nm %||% glue("doc_index_{index}")) } #' @rdname officer_tables @@ -145,7 +145,7 @@ officer_table <- function(x, body_cells <- table_cells header_cells <- data.frame() - if (rlang::has_name(x, "is_header")) { + if (has_name(x, "is_header")) { header_cells <- officer_table_pivot(subset_header(table_cells, TRUE)) body_cells <- subset_header(table_cells, FALSE) } @@ -189,7 +189,7 @@ officer_table <- function(x, nm <- utils::head(body_cells, 1) return( - rlang::set_names( + set_names( utils::tail(body_cells, n_body_rows - 1), nm ) @@ -204,7 +204,7 @@ officer_table <- function(x, body_cells[[col]] <- rep(col_value, n_body_rows) } - return(rlang::set_names(body_cells, nm)) + return(set_names(body_cells, nm)) } list(body_cells, header_cells) @@ -215,9 +215,9 @@ officer_table <- function(x, #' @importFrom rlang has_name officer_table_index <- function(x) { tables <- subset_type(x, "table cell") - if (rlang::has_name(x, "doc_index")) { + if (has_name(x, "doc_index")) { unique(tables[["doc_index"]]) - } else if (rlang::has_name(x, "id")) { + } else if (has_name(x, "id")) { unique(tables[["id"]]) } } diff --git a/R/write_officer.R b/R/write_officer.R index 6263e0c..f484f41 100644 --- a/R/write_officer.R +++ b/R/write_officer.R @@ -21,19 +21,17 @@ write_officer <- function(x, overwrite = TRUE, modified_by = Sys.getenv("USER"), ...) { - rlang::check_required(x) - rlang::check_required(path) + check_officer(x, call = current_call()) - check_officer(x, call = rlang::current_call()) check_office_fileext( path, fileext = c("docx", "pptx", "xlsx"), - call = rlang::current_call() + call = current_call() ) is_xlsx <- isTRUE(is_fileext_path(path, "xlsx")) - if (isFALSE(rlang::is_empty(rlang::list2(...))) && !is_xlsx) { + if (isFALSE(is_empty(list2(...))) && !is_xlsx) { x <- officer::set_doc_properties( x, @@ -51,7 +49,7 @@ write_officer <- function(x, file.remove(path) } - if (!rlang::is_installed("withr")) { + if (!is_installed("withr")) { print(x, target = path) } else { withr::with_envvar(