Skip to content

Commit

Permalink
internals: adapt to r-devel
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgohel committed Oct 22, 2023
1 parent 9241ade commit 58f5c52
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: officer
Type: Package
Title: Manipulation of Microsoft Word and PowerPoint Documents
Version: 0.6.3.005
Version: 0.6.3.006
Authors@R: c(
person("David", "Gohel", role = c("aut", "cre"),
email = "david.gohel@ardata.fr"),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ S3method(to_rtf,external_img)
S3method(to_rtf,fpar)
S3method(to_rtf,ftext)
S3method(to_rtf,hyperlink_ftext)
S3method(to_rtf,page_mar)
S3method(to_rtf,page_size)
S3method(to_rtf,prop_section)
S3method(to_rtf,run_autonum)
Expand All @@ -105,6 +106,7 @@ S3method(to_wml,block_pour_docx)
S3method(to_wml,block_section)
S3method(to_wml,block_table)
S3method(to_wml,block_toc)
S3method(to_wml,docx_settings)
S3method(to_wml,external_img)
S3method(to_wml,fp_cell)
S3method(to_wml,fp_par)
Expand Down
2 changes: 1 addition & 1 deletion R/docx_comments.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ docx_comments <- function(x) {

if (length(comment_nodes) > 0) {
data <- lapply(comment_nodes, comment_as_tibble)
data <- rbind.match.columns(data)
data <- rbind_match_columns(data)
} else {
data <- data.frame(
comment_id = integer(0),
Expand Down
1 change: 1 addition & 0 deletions R/docx_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ update.docx_settings <- function(object,
object
}

#' @export
to_wml.docx_settings <- function(x, add_ns = FALSE, ...) {
out <- paste0(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n",
Expand Down
8 changes: 4 additions & 4 deletions R/fortify_docx.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ unfold_row_wml <- function(node, row_id, preserve = FALSE){
stringsAsFactors = FALSE
)
})
row_span <- rbind.match.columns(row_span)
row_span <- rbind_match_columns(row_span)
txt[row_span$row_merge & !row_span$first] <- NA

out <- data.frame(row_id = row_id, is_header = is_header,
Expand Down Expand Up @@ -58,7 +58,7 @@ unfold_row_wml <- function(node, row_id, preserve = FALSE){
out_add_$col_span, out_add_$row_merge, out_add_$first, out_add_$row_span,
SIMPLIFY = FALSE)
if( length(out_add_) > 0 ){
out_add_ <- rbind.match.columns(out_add_)
out_add_ <- rbind_match_columns(out_add_)
out <- rbind(out, out_add_)
}
out[order(out$cell_id),]
Expand All @@ -71,7 +71,7 @@ docxtable_as_tibble <- function( node, styles, preserve = FALSE ){
if( length(rows) < 1 ) return(NULL)

row_details <- mapply(unfold_row_wml, rows, seq_along(rows), preserve = preserve, SIMPLIFY = FALSE)
row_details <- rbind.match.columns(row_details)
row_details <- rbind_match_columns(row_details)
row_details <- set_row_span(row_details)

style_node <- xml_child(node, "w:tblPr/w:tblStyle")
Expand Down Expand Up @@ -146,7 +146,7 @@ docx_summary <- function( x, preserve = FALSE ){
x$doc_index <- id
x
}, data, seq_along(data), SIMPLIFY = FALSE)
data <- rbind.match.columns(data)
data <- rbind_match_columns(data)

colnames <- c("doc_index", "content_type", "style_name", "text",
"level", "num_id", "row_id", "is_header", "cell_id",
Expand Down
8 changes: 4 additions & 4 deletions R/fortify_pptx.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ unfold_row_pml <- function(node, row_id, preserve = FALSE){
stringsAsFactors = FALSE
)
})
row_span <- rbind.match.columns(row_span)
row_span <- rbind_match_columns(row_span)
row_span$row_merge <- !is.na(row_span$v_merged) | !is.na(row_span$row_span)
row_span$first <- !is.na(row_span$row_span)
row_span$row_span[!is.na(row_span$v_merged)] <- 0L
Expand All @@ -53,7 +53,7 @@ pptxtable_as_tibble <- function( node, preserve = FALSE ){
rows <- xml_find_all(node, xpath_)
if( length(rows) < 1 ) return(NULL)
row_details <- mapply(unfold_row_pml, rows, seq_along(rows), preserve = preserve, SIMPLIFY = FALSE)
row_details <- rbind.match.columns(row_details)
row_details <- rbind_match_columns(row_details)
row_details <- set_row_span(row_details)
row_details$text[row_details$col_span < 1 | row_details$row_span < 1] <- NA_character_
row_details
Expand Down Expand Up @@ -166,8 +166,8 @@ pptx_summary <- function( x, preserve = FALSE ){
}
}, nodes, slide_id = i, SIMPLIFY = FALSE)

list_content[[length(list_content)+1]] <- rbind.match.columns(content)
list_content[[length(list_content)+1]] <- rbind_match_columns(content)
}

rbind.match.columns(list_content)
rbind_match_columns(list_content)
}
2 changes: 1 addition & 1 deletion R/ooxml_block_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ as.data.frame.fpar <- function( x, ...){
bold = x$pr$bold, italic = x$pr$italic,
font.family = x$pr$font.family, stringsAsFactors = FALSE )
}, chks, SIMPLIFY = FALSE)
rbind.match.columns(chks)
rbind_match_columns(chks)
}

#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/ppt_class_dir_collection.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dir_collection <- R6Class(

get_metadata = function(){
dat <- lapply(private$collection, function(x) x$get_metadata())
rbind.match.columns(dat)
rbind_match_columns(dat)
},
names = function(){
sapply(private$collection, function(x) x$name())
Expand Down Expand Up @@ -195,7 +195,7 @@ dir_master <- R6Class(
},
get_color_scheme = function( ){
dat <- lapply(private$collection, function(x) x$colors())
rbind.match.columns(dat)
rbind_match_columns(dat)
}

)
Expand Down
1 change: 1 addition & 0 deletions R/rtf.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ guess_hfr_type <- function(x) {
}
}

#' @export
to_rtf.page_mar <- function(x, ...) {
sprintf(
"\\margb%.0f\\margt%.0f\\margr%.0f\\margl%.0f\\gutter%.0f\\headery%.0f\\footery%.0f",
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ simple_lag <- function( x, default=0 ){
c(default, x[-length(x)])
}

rbind.match.columns <- function(list_df) {
rbind_match_columns <- function(list_df) {

col <- unique(unlist(lapply(list_df, colnames)))
x <- Filter(function(x) nrow(x)>0, list_df)
Expand All @@ -178,7 +178,7 @@ set_row_span <- function( row_details ){
dat$row_span[rowspan_pos_at_breaks] <- rowspan_values_at_breaks
dat
}, row_details, SIMPLIFY = FALSE)
row_details <- rbind.match.columns(row_details)
row_details <- rbind_match_columns(row_details)
row_details$first <- NULL
row_details
}
Expand Down

0 comments on commit 58f5c52

Please sign in to comment.