diff --git a/DESCRIPTION b/DESCRIPTION index 02f6cdd5..7ab5ac43 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: officer Title: Manipulation of Microsoft Word and PowerPoint Documents -Version: 0.6.7.011 +Version: 0.6.7.012 Authors@R: c( person("David", "Gohel", , "david.gohel@ardata.fr", role = c("aut", "cre")), person("Stefan", "Moog", , "moogs@gmx.de", role = "aut"), diff --git a/NAMESPACE b/NAMESPACE index 272e58df..9c71694e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,14 @@ # Generated by roxygen2: do not edit by hand +S3method("[",core_properties) +S3method("[",custom_properties) +S3method("[<-",core_properties) +S3method("[<-",custom_properties) S3method(as.character,fp_tab) S3method(as.character,fp_tabs) +S3method(as.character,officer_cursor) +S3method(as.data.frame,external_img) +S3method(as.data.frame,fpar) S3method(as.matrix,rpptx) S3method(body_add,block_caption) S3method(body_add,block_list) @@ -18,6 +25,7 @@ S3method(body_add,numeric) S3method(body_add,plot_instr) S3method(body_add,run_columnbreak) S3method(body_add,run_pagebreak) +S3method(dim,external_img) S3method(format,fp_cell) S3method(format,fp_par) S3method(format,fp_text) @@ -31,6 +39,8 @@ S3method(fortify_location,location_type) S3method(length,rdocx) S3method(length,rpptx) S3method(length,rxlsx) +S3method(ph_from_location,location_label) +S3method(ph_from_location,location_type) S3method(ph_with,block_list) S3method(ph_with,character) S3method(ph_with,data.frame) diff --git a/R/core_properties.R b/R/core_properties.R index 7972ad30..fddac535 100644 --- a/R/core_properties.R +++ b/R/core_properties.R @@ -51,6 +51,8 @@ default_cp_tags <- list( category = list(ns = "cp", attrs = NA_character_) ) + +#' @export `[<-.core_properties` <- function( x, i, j, value ){ if( !i %in% x$data[,"name"] ) { attrs <- ifelse(is.na(default_cp_tags[[i]]$attrs), "", paste0(" ", default_cp_tags[[i]]$attrs)) @@ -61,10 +63,14 @@ default_cp_tags <- list( } x } + + +#' @export `[.core_properties` <- function( x, i, j ){ x$data[i,j] } + write_core_properties <- function(core_matrix, package_dir){ ns_ <- core_matrix$ns core_matrix <- core_matrix$data diff --git a/R/custom_properties.R b/R/custom_properties.R index ada8b1b9..0bd6afb5 100644 --- a/R/custom_properties.R +++ b/R/custom_properties.R @@ -36,6 +36,8 @@ read_custom_properties <- function(package_dir) { z } + +#' @export `[<-.custom_properties` <- function(x, i, j, value) { if (!i %in% x$data[, "name"]) { if (nrow(x$data) < 1) { @@ -50,6 +52,9 @@ read_custom_properties <- function(package_dir) { } x } + + +#' @export `[.custom_properties` <- function(x, i, j) { if (nrow(x$data) < 1) { return(character()) diff --git a/R/docx_cursor.R b/R/docx_cursor.R index 2a32ac7a..7a621acf 100644 --- a/R/docx_cursor.R +++ b/R/docx_cursor.R @@ -207,6 +207,9 @@ officer_cursor <- function(node) { class(x) <- "officer_cursor" x } + + +#' @export as.character.officer_cursor <- function(x, ...) { if (length(x$nodes_names) < 1) { return(NA_character_) diff --git a/R/ooxml_block_objects.R b/R/ooxml_block_objects.R index 8b09bcf0..7ce2f2dc 100644 --- a/R/ooxml_block_objects.R +++ b/R/ooxml_block_objects.R @@ -886,6 +886,7 @@ fortify_fpar <- function(x){ } +#' @export as.data.frame.fpar <- function( x, ...){ chks <- fortify_fpar(x) chks <- chks[sapply(chks, function(x) inherits(x, "ftext"))] @@ -897,6 +898,7 @@ as.data.frame.fpar <- function( x, ...){ rbind_match_columns(chks) } + #' @export to_wml.fpar <- function(x, add_ns = FALSE, style_id = NULL, ...) { diff --git a/R/ooxml_run_objects.R b/R/ooxml_run_objects.R index b153bb28..ad7f593d 100644 --- a/R/ooxml_run_objects.R +++ b/R/ooxml_run_objects.R @@ -1050,11 +1050,15 @@ external_img <- function(src, width = .5, height = .2, unit = "in", guess_size = src } + +#' @export dim.external_img <- function(x) { x <- attr(x, "dims") data.frame(width = x$width, height = x$height) } + +#' @export as.data.frame.external_img <- function(x, ...) { dimx <- attr(x, "dims") data.frame(path = as.character(x), width = dimx$width, height = dimx$height, alt = attr(x, "alt"), stringsAsFactors = FALSE) diff --git a/R/ppt_notes.R b/R/ppt_notes.R index 7a62f081..4fd713cb 100644 --- a/R/ppt_notes.R +++ b/R/ppt_notes.R @@ -143,6 +143,7 @@ ph_from_location <- function(loc, doc, ...){ } +#' @export ph_from_location.location_label <- function(loc, doc, ...) { xfrm <- doc$notesMaster$xfrm() location <- xfrm[xfrm$ph_label == loc$ph_label, ] @@ -155,6 +156,7 @@ ph_from_location.location_label <- function(loc, doc, ...) { } +#' @export ph_from_location.location_type <- function(loc, doc, ...) { xfrm <- doc$notesMaster$xfrm() location <- xfrm[xfrm$type == loc$type, ]